Plan 9 from Bell Labs’s /usr/web/sources/extra/changes/2005/1106

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Add untested code to recognize SIS900 and WPC-11 ethernet cards.

Move PC kernel to 0xF0000000, rewrite PC mmu.c accordingly.
Make memory banks described by array inside of hard-coding two banks.
On PC, add E820 memory map scan and VGA VESA support.
 [rsc] --rw-rw-r-- M 451989 glenda sys 23542 Nov  6 09:32 sys/src/9/pc/ether83815.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether83815.c:81,86 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether83815.c:81,87
	  
	  enum {				/* Variants */
	  	Nat83815	= (0x0020<<16)|0x100B,
	+ 	Sis900 = (0x0630<<16)|0x1039,	/* untested */
	  };
	  
	  typedef struct Ctlr Ctlr;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether83815.c:841,846 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether83815.c:842,848
	  			continue;
	  
	  		case Nat83815:
	+ 		case Sis900:
	  			break;
	  		}
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 630 Nov  6 10:08 sys/src/9/alphapc/apc
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/apc:36,42 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/apc:36,42
	  	arch164
	  
	  	sdata		pci sdscsi
	- 	sd53c8xx	pci sdscsi
	+ #	sd53c8xx	pci sdscsi
	  
	  	uarti8250
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 5196 Nov  6 10:08 sys/src/9/alphapc/dat.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/dat.h:1,4 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/dat.h:1,5
	  typedef struct Conf	Conf;
	+ typedef struct Confmem	Confmem;
	  typedef struct FPsave	FPsave;
	  typedef struct ISAConf	ISAConf;
	  typedef struct Label	Label;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/dat.h:32,37 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/dat.h:33,39
	  	ulong	sr;
	  	ulong	pc;
	  	Proc	*p;
	+ 	Mach	*m;
	  	ulong	pid;
	  	ushort	isilock;
	  };
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/dat.h:63,77 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/dat.h:65,84
	  	long	fpstatus;
	  };
	  
	+ struct Confmem
	+ {
	+ 	ulong	base;
	+ 	ulong	npage;
	+ 	ulong	kbase;
	+ 	ulong	klimit;
	+ };
	+ 
	  struct Conf
	  {
	  	ulong	nmach;		/* processors */
	  	ulong	nproc;		/* processes */
	- 	ulong	npage0;		/* total physical pages of memory */
	- 	ulong	npage1;		/* total physical pages of memory */
	+ 	Confmem	mem[2];
	  	ulong	npage;		/* total physical pages of memory */
	- 	ulong	base0;		/* base of bank 0 */
	- 	ulong	base1;		/* base of bank 1 */
	  	ulong	upages;		/* user page pool */
	  	ulong	nimage;		/* number of page cache image headers */
	  	ulong	nswap;		/* number of swap pages */
 [rsc] --rw-rw-r-- M 451989 glenda sys 7420 Nov  6 10:08 sys/src/9/alphapc/devvga.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/devvga.c:130,139 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/devvga.c:130,136
	  		len += snprint(p+len, READSTR-len, "blanktime %lud\n", blanktime);
	  		len += snprint(p+len, READSTR-len, "hwaccel %s\n", hwaccel ? "on" : "off");
	  		len += snprint(p+len, READSTR-len, "hwblank %s\n", hwblank ? "on" : "off");
	- 		if(scr->pciaddr)
	- 			snprint(p+len, READSTR-len, "addr 0x%lux\n", scr->pciaddr);
	- 		else
	- 			snprint(p+len, READSTR-len, "addr 0x%lux\n", scr->aperture);
	+ 		snprint(p+len, READSTR-len, "addr 0x%lux\n", scr->paddr);
	  		n = readstr(offset, a, n, p);
	  		poperror();
	  		free(p);
 [rsc] --rw-rw-r-- M 451989 glenda sys 3613 Nov  6 10:08 sys/src/9/alphapc/fns.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/fns.h:98,108 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/fns.h:98,110
	  void	touser(void*);
	  void	trapinit(void);
	  void	unaligned(void);
	- ulong	upamalloc(ulong, int, int);
	+ ulong	upaalloc(int, int);
	  void	upafree(ulong, int);
	  #define	userureg(ur) ((ur)->status & UMODE)
	+ void*	vmap(ulong, int);
	  void	wrent(int, void*);
	  void	wrvptptr(uvlong);
	+ void	vunmap(void*, int);
	  
	  #define	waserror()	(up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
	  #define KADDR(a)	((void*)((ulong)(a)|KZERO))
 [rsc] --rw-rw-r-- M 451989 glenda sys 13672 Nov  6 10:08 sys/src/9/alphapc/main.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/main.c:454,470 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/main.c:454,470
	  	 * allocating low memory pages from bank 0 for any peripherals
	  	 * which only have a 24bit address counter.
	  	 */
	- 	conf.npage0 = (8*1024*1024)/BY2PG;
	- 	conf.base0 = 0;
	+ 	conf.mem[0].npage = (8*1024*1024)/BY2PG;
	+ 	conf.mem[0].base = 0;
	  
	- 	conf.npage1 = (b->max-8*1024*1024)/BY2PG;
	- 	conf.base1 = 8*1024*1024;
	+ 	conf.mem[1].npage = (b->max-8*1024*1024)/BY2PG;
	+ 	conf.mem[1].base = 8*1024*1024;
	  
	- 	conf.npage = conf.npage0+conf.npage1;
	+ 	conf.npage = conf.mem[0].npage+conf.mem[1].npage;
	  	conf.upages = (conf.npage*70)/100;
	  
	- 	conf.npage0 -= ktop/BY2PG;
	- 	conf.base0 += ktop;
	+ 	conf.mem[0].npage -= ktop/BY2PG;
	+ 	conf.mem[0].base += ktop;
	  	conf.ialloc = ((conf.npage-conf.upages)/2)*BY2PG;
	  
	  	/*
 [rsc] --rw-rw-r-- M 451989 glenda sys 4945 Nov  6 10:08 sys/src/9/alphapc/mmu.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/mmu.c:224,231 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/mmu.c:224,231
	  
	  }
	  
	- ulong
	- upamalloc(ulong pa, int size, int align)
	+ void*
	+ vmap(ulong pa, int size)
	  {
	  	void *va;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/mmu.c:234,250 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/mmu.c:234,249
	  	 */
	  	if(pa == 0)
	  		return 0;
	- 	USED(align);
	  	va = kmapv(((uvlong)0x88<<32LL)|pa, size);
	  	if(va == nil)
	  		return 0;
	- 	return PADDR(va);
	+ 	return (void*)va;
	  }
	  
	  void
	- upafree(ulong, int)
	+ vunmap(void*, int)
	  {
	- 	print("upafree: virtual mapping not freed\n");
	+ 	print("vunmap: virtual mapping not freed\n");
	  }
	  
	  void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/mmu.c:263,266 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/mmu.c:262,280
	  	}
	  }
	  
	- void checkmmu(ulong, ulong) { }
	+ ulong
	+ upaalloc(int, int)
	+ {
	+ 	return 0;
	+ }
	+ 
	+ void
	+ upafree(ulong, int)
	+ {
	+ }
	+ 
	+ void
	+ checkmmu(ulong, ulong)
	+ {
	+ }
	+ 
 [rsc] --rw-rw-r-- M 451989 glenda sys 3818 Nov  6 10:08 sys/src/9/alphapc/screen.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/screen.h:68,74 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/screen.h:68,74
	  	void	(*enable)(VGAscr*);
	  	void	(*disable)(VGAscr*);
	  	void	(*page)(VGAscr*, int);
	- 	ulong	(*linear)(VGAscr*, int*, int*);
	+ 	void	(*linear)(VGAscr*, int, int);
	  	void	(*drawinit)(VGAscr*);
	  	int	(*fill)(VGAscr*, Rectangle, ulong);
	  	void (*flush)(VGAscr*, Rectangle);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/screen.h:91,96 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/screen.h:91,97
	  struct VGAscr {
	  	Lock	devlock;
	  	VGAdev*	dev;
	+ 	Pcidev*	pci;
	  
	  	VGAcur*	cur;
	  	ulong	storage;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/screen.h:98,114 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/screen.h:99,114
	  
	  	int	useflush;
	  
	- 	ulong	aperture;			/* physical address, kernel */
	- 	ulong	pciaddr;			/* physical address, user */
	- 	int	isupamem;
	+ 	ulong	paddr;		/* frame buffer */
	+ 	void*	vaddr;
	  	int	apsize;
	  
	  	ulong	io;				/* device specific registers */
	- 
	+ 	ulong	*mmio;
	+ 	
	  	ulong	colormap[Pcolours][3];
	  	int	palettedepth;
	  
	- 	ulong	*mmio;
	  	Memimage* gscreen;
	  	Memdata* gscreendata;
	  	Memsubfont* memdefont;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/screen.h:142,155 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/screen.h:142,168
	  extern Rectangle physgscreenr;	/* actual monitor size */
	  extern void	blankscreen(int);
	  
	+ extern VGAcur swcursor;
	+ extern void swcursorinit(void);
	+ extern void swcursorhide(void);
	+ extern void swcursoravoid(Rectangle);
	+ extern void swcursorunhide(void);
	+ 
	  /* devdraw.c */
	  extern void	deletescreenimage(void);
	  extern int	drawhasclients(void);
	  extern ulong	blanktime;
	+ extern QLock	drawlock;
	+ 
	  /* vga.c */
	  extern void	vgascreenwin(VGAscr*);
	  extern void	vgaimageinit(ulong);
	- extern ulong	vgapcilinear(VGAscr*, int*, int*, int, int);
	+ extern void	vgalinearpciid(VGAscr*, int, int);
	+ extern void	vgalinearpci(VGAscr*);
	+ extern void	vgalinearaddr(VGAscr*, ulong, int);
	  
	  extern void	drawblankscreen(int);
	  extern void	vgablank(VGAscr*, int);
	+ 
	+ extern Lock	vgascreenlock;
	+ 
 [rsc] --rw-rw-r-- M 451989 glenda sys 50963 Nov  6 10:08 sys/src/9/alphapc/sd53c8xx.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/alphapc/sd53c8xx.c:1817,1824 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/alphapc/sd53c8xx.c:1817,1822
	  { SYM_1010_DID,  0xff, "SYM53C1010",	Burst128, 16, 64, Prefetch|LocalRAM|BigFifo|Wide|Ultra|Ultra2 },
	  };
	  
	- #define offsetof(s, t) ((ulong)&((s *)0)->t)
	- 
	  static int
	  xfunc(Controller *c, enum na_external x, unsigned long *v)
	  {
 [rsc] --rw-rw-r-- M 451989 glenda bitsy 5829 Nov  6 10:09 sys/src/9/bitsy/dat.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/dat.h:1,5 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/dat.h:1,6
	  typedef struct Cisdat 		Cisdat;
	  typedef struct Conf		Conf;
	+ typedef struct Confmem	Confmem;
	  typedef struct FPU		FPU;
	  typedef struct FPenv		FPenv;
	  typedef struct FPsave		FPsave;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/dat.h:37,42 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/dat.h:38,44
	  	ulong	sr;
	  	ulong	pc;
	  	Proc	*p;
	+ 	Mach	*m;
	  	ushort	isilock;
	  };
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/dat.h:62,80 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/dat.h:64,88
	  	ulong	regs[8][3];	/* emulated fp */	
	  };
	  
	+ struct Confmem
	+ {
	+ 	ulong	base;
	+ 	ulong	npage;
	+ 	ulong	limit;
	+ 	ulong	kbase;
	+ 	ulong	klimit;
	+ };
	+ 
	  struct Conf
	  {
	  	ulong	nmach;		/* processors */
	  	ulong	nproc;		/* processes */
	- 	ulong	npage0;		/* total physical pages of memory */
	- 	ulong	npage1;		/* total physical pages of memory */
	+ 	Confmem	mem[2];
	  	ulong	npage;		/* total physical pages of memory */
	  	ulong	upages;		/* user page pool */
	  	ulong	nimage;		/* number of page cache image headers */
	  	ulong	nswap;		/* number of swap pages */
	  	int	nswppo;		/* max # of pageouts per segment pass */
	- 	ulong	base0;		/* base of bank 0 */
	- 	ulong	base1;		/* base of bank 1 */
	  	ulong	copymode;	/* 0 is copy on write, 1 is copy on reference */
	  	int	monitor;
	  	ulong	ialloc;		/* bytes available for interrupt time allocation */
 [rsc] --rw-rw-r-- M 451989 glenda bitsy 9589 Nov  6 10:09 sys/src/9/bitsy/devpenmouse.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/devpenmouse.c:53,58 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/devpenmouse.c:53,60
	  	Lock;
	  	Mousestate;
	  	ulong	lastcounter;	/* value when /dev/mouse read */
	+ 	ulong	resize;
	+ 	ulong	lastresize;
	  	Rendez	r;
	  	Ref;
	  	QLock;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/devpenmouse.c:285,290 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/devpenmouse.c:287,296
	  		mouse.lastcounter = m.counter;
	  		if(n > 1+4*12)
	  			n = 1+4*12;
	+ 		if(mouse.lastresize != mouse.resize){
	+ 			mouse.lastresize = mouse.resize;
	+ 			buf[0] = 'r';
	+ 		}
	  		memmove(va, buf, n);
	  		return n;
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/devpenmouse.c:481,487 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/devpenmouse.c:487,494
	  int
	  penmousechanged(void*)
	  {
	- 	return mouse.lastcounter != mouse.counter;
	+ 	return mouse.lastcounter != mouse.counter ||
	+ 		mouse.lastresize != mouse.resize;
	  }
	  
	  Point
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/devpenmouse.c:489,491 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/devpenmouse.c:496,509
	  {
	  	return mouse.xy;
	  }
	+ 
	+ /*
	+  * notify reader that screen has been resized (ha!)
	+  */
	+ void
	+ mouseresize(void)
	+ {
	+ 	mouse.resize++;
	+ 	wakeup(&mouse.r);
	+ }
	+ 
 [rsc] --rw-rw-r-- M 451989 glenda bitsy 8816 Nov  6 10:09 sys/src/9/bitsy/main.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/main.c:268,273 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/main.c:268,274
	  int
	  probemem(ulong addr)
	  {
	+ 	int i;
	  	ulong *p;
	  	ulong a;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/main.c:274,287 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/main.c:275,286
	  	addr += OneMeg - sizeof(ulong);
	  	p = (ulong*)addr;
	  	*p = addr;
	- 	for(a = conf.base0+OneMeg-sizeof(ulong); a < conf.npage0; a += OneMeg){
	- 		p = (ulong*)a;
	- 		*p = 0;
	+ 	for(i=0; i<nelem(conf.mem); i++){
	+ 		for(a = conf.mem[i].base+OneMeg-sizeof(ulong); a < conf.mem[i].limit; a += OneMeg){
	+ 			p = (ulong*)a;
	+ 			*p = 0;
	+ 		}
	  	}
	- 	for(a = conf.base1+OneMeg-sizeof(ulong); a < conf.npage1; a += OneMeg){
	- 		p = (ulong*)a;
	- 		*p = 0;
	- 	}
	  	p = (ulong*)addr;
	  	if(*p != addr)
	  		return -1;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/main.c:295,350 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/main.c:294,339
	  void
	  confinit(void)
	  {
	- 	int i;
	+ 	int i, j;
	  	ulong addr;
	  	ulong ktop;
	  
	  	/* find first two contiguous sections of available memory */
	  	addr = PHYSDRAM0;
	- 	conf.base0 = conf.npage0 = addr;
	- 	conf.base1 = conf.npage1 = addr;
	- 	for(i = 0; i < 512; i++){
	- 		if(probemem(addr) == 0)
	- 			break;
	- 		addr += OneMeg;
	+ 	for(i=0; i<nelem(conf.mem); i++){
	+ 		conf.mem[i].base = addr;
	+ 		conf.mem[i].limit = addr;
	  	}
	- 	for(; i < 512; i++){
	- 		if(probemem(addr) < 0)
	- 			break;
	- 		addr += OneMeg;
	- 		conf.npage0 = addr;
	+ 	for(j=0; j<nelem(conf.mem); j++){
	+ 		conf.mem[j].base = addr;
	+ 		conf.mem[j].limit = addr;
	+ 		
	+ 		for(i = 0; i < 512; i++){
	+ 			if(probemem(addr) == 0)
	+ 				break;
	+ 			addr += OneMeg;
	+ 		}
	+ 		for(; i < 512; i++){
	+ 			if(probemem(addr) < 0)
	+ 				break;
	+ 			addr += OneMeg;
	+ 			conf.mem[j].limit = addr;
	+ 		}
	  	}
	+ 	
	+ 	conf.npage = 0;
	+ 	for(i=0; i<nelem(conf.mem); i++){
	+ 		/* take kernel out of allocatable space */
	+ 		ktop = PGROUND((ulong)end);
	+ 		if(ktop >= conf.mem[i].base && ktop <= conf.mem[i].limit)
	+ 			conf.mem[i].base = ktop;
	+ 		
	+ 		/* zero memory */
	+ 		memset((void*)conf.mem[i].base, 0, conf.mem[i].limit - conf.mem[i].base);
	  
	- 	conf.base1 = conf.npage1 = addr;
	- 	for(; i < 512; i++){
	- 		if(probemem(addr) == 0)
	- 			break;
	- 		addr += OneMeg;
	+ 		conf.mem[i].npage = (conf.mem[i].limit - conf.mem[i].base)/BY2PG;
	+ 		conf.npage += conf.mem[i].npage;
	  	}
	- 	for(; i < 512; i++){
	- 		if(probemem(addr) < 0)
	- 			break;
	- 		addr += OneMeg;
	- 		conf.npage1 = addr;
	- 	}
	- 
	- 	/* take kernel out of allocatable space */
	- 	ktop = PGROUND((ulong)end);
	- 	if(ktop >= conf.base0 && ktop <= conf.npage0)
	- 		conf.base0 = ktop;
	- 	else if(ktop >= conf.base1 && ktop <= conf.npage1)
	- 		conf.base1 = ktop;
	- 	else
	- 		iprint("kernel not in allocatable space\n");
	- 
	- 	/* zero memory */
	- 	memset((void*)conf.base0, 0, conf.npage0 - conf.base0);
	- 	memset((void*)conf.base1, 0, conf.npage1 - conf.base1);
	- 
	- 	/* make npage the right thing */
	- 	conf.npage0 = (conf.npage0 - conf.base0)/BY2PG;
	- 	conf.npage1 = (conf.npage1 - conf.base1)/BY2PG;
	- 	conf.npage = conf.npage0+conf.npage1;
	  
	  	if(conf.npage > 16*MB/BY2PG){
	  		conf.upages = (conf.npage*60)/100;
 [rsc] --rw-rw-r-- M 451989 glenda bitsy 2459 Nov  6 10:09 sys/src/9/bitsy/mkfile
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/mkfile:104,110 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/mkfile:104,110
	  	$AS init9.s
	  	$LD -l -R1 -o init.out init9.$O initcode.$O /arm/lib/libc.a
	  	{echo 'uchar initcode[]={'
	- 	 strip < init.out | xd -1x |
	+ 	 strip -o /fd/1 init.out | xd -1x |
	  		sed -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
	  	 echo '};'} > init.h
	  
 [rsc] --rw-rw-r-- M 451989 glenda bitsy 44404 Nov  6 10:09 sys/src/9/bitsy/sdata.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/sdata.c:742,747 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/sdata.c:742,748
	  
	  	sdev->ifc = &sdataifc;
	  	sdev->ctlr = ctlr;
	+ 	sdev->idno = 'C';
	  	sdev->nunit = 1;
	  	ctlr->sdev = sdev;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/sdata.c:1571,1596 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/sdata.c:1572,1577
	  	return ataprobe(port, port+0x204, irq);
	  }
	  
	- static SDev*
	- ataid(SDev* sdev)
	- {
	- 	int i;
	- 
	- 	if(sdev == nil)
	- 		return nil;
	- 	i = 0;
	- 	while(sdev){
	- 		if(sdev->ifc == &sdataifc){
	- 			sdev->idno = 'C'+i;
	- 			i++;
	- 			snprint(sdev->name, KNAMELEN, "sd%c", sdev->idno);
	- 		}
	- 		sdev = sdev->next;
	- 	}
	- 
	- 	return nil;
	- }
	- 
	  static int ataitype;
	  static int atairq;
	  static int
	/n/sourcesdump/2005/1106/plan9/sys/src/9/bitsy/sdata.c:2089,2095 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/bitsy/sdata.c:2070,2075
	  
	  	nil,				/* pnp */
	  	atalegacy,			/* legacy */
	- 	ataid,				/* id */
	  	ataenable,			/* enable */
	  	nil,				/* disable */
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 1160 Nov  6 10:09 sys/src/9/boot/bootauth.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/boot/bootauth.c:22,28 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/boot/bootauth.c:22,30
	  	ac = 0;
	  	av = argv;
	  	av[ac++] = "factotum";
	- //av[ac++] = "-d";
	+ 	if(getenv("debugfactotum"))
	+ 		av[ac++] = "-p";
	+ //av[ac++] = "-d";	//debug traces
	  //av[ac++] = "-D";	//9p messages
	  	if(cpuflag)
	  		av[ac++] = "-S";
 [rsc] --rw-rw-r-- M 451989 glenda sys 3843 Nov  6 10:10 sys/src/9/mtx/dat.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/mtx/dat.h:1,4 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/mtx/dat.h:1,5
	  typedef struct Conf	Conf;
	+ typedef struct Confmem	Confmem;
	  typedef struct FPsave	FPsave;
	  typedef struct ISAConf	ISAConf;
	  typedef struct Label	Label;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/mtx/dat.h:33,39 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/mtx/dat.h:34,40
	  	ulong	sr;
	  	ulong	pc;
	  	Proc	*p;
	- 	ulong	pid;
	+ 	Mach	*m;
	  	ushort	isilock;
	  };
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/mtx/dat.h:68,82 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/mtx/dat.h:69,88
	  	};
	  };
	  
	+ struct Confmem
	+ {
	+ 	ulong	base;
	+ 	ulong	npage;
	+ 	ulong	kbase;
	+ 	ulong	klimit;
	+ };
	+ 
	  struct Conf
	  {
	  	ulong	nmach;		/* processors */
	  	ulong	nproc;		/* processes */
	- 	ulong	npage0;		/* total physical pages of memory */
	- 	ulong	npage1;		/* total physical pages of memory */
	+ 	Confmem	mem[1];
	  	ulong	npage;		/* total physical pages of memory */
	- 	ulong	base0;		/* base of bank 0 */
	- 	ulong	base1;		/* base of bank 1 */
	  	ulong	upages;		/* user page pool */
	  	ulong	nimage;		/* number of page cache image headers */
	  	ulong	nswap;		/* number of swap pages */
 [rsc] --rw-rw-r-- M 451989 glenda sys 8307 Nov  6 10:10 sys/src/9/mtx/main.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/mtx/main.c:288,300 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/mtx/main.c:288,296
	  
	  	pa = PGROUND(PADDR(end));
	  
	- 	conf.npage0 = memsize/BY2PG;
	- 	conf.base0 = pa;
	- 	
	- 	conf.npage1 = 0;
	- 	conf.base1 = pa;
	- 
	- 	conf.npage = conf.npage0 + conf.npage1;
	+ 	conf.mem[0].npage = memsize/BY2PG;
	+ 	conf.mem[0].base = pa;
	+ 	conf.npage = conf.mem[0].npage;
	  
	  	conf.nmach = 1;
	  	conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5;
 [rsc] --rw-rw-r-- M 451989 glenda sys 8748 Nov  6 10:16 sys/src/9/pc/apic.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/apic.c:376,378 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/apic.c:376,391
	  {
	  	timerintr(u, 0);
	  }
	+ 
	+ void
	+ lapicintron(void)
	+ {
	+ 	lapicw(LapicTPR, 0);
	+ }
	+ 
	+ void
	+ lapicintroff(void)
	+ {
	+ 	lapicw(LapicTPR, 0xFF);
	+ }
	+ 
 [rsc] --rw-rw-r-- M 451989 glenda sys 3723 Nov  6 10:16 sys/src/9/pc/apm.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/apm.c:103,108 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/apm.c:103,110
	  	if(isaconfig("apm", 0, &isa) == 0)
	  		return;
	  
	+ /* XXX use realmode() */
	+ 
	  	/*
	  	 * APM info passed from boot loader.
	  	 * Now we need to set up the GDT entries for APM.
 [rsc] --rw-rw-r-- M 451989 glenda sys 2357 Nov  6 10:16 sys/src/9/pc/archmp.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/archmp.c:62,67 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/archmp.c:62,69
	  .reset=		mpshutdown,
	  .intrinit=	mpinit,
	  .intrenable=	mpintrenable,
	+ .intron=	lapicintron,
	+ .introff=	lapicintroff,
	  .fastclock=	i8253read,
	  .timerset=	lapictimerset,
	  };
 [rsc] --rw-rw-r-- M 451989 glenda sys 6462 Nov  6 10:16 sys/src/9/pc/dat.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/dat.h:1,4 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/dat.h:1,5
	  typedef struct Conf	Conf;
	+ typedef struct Confmem	Confmem;
	  typedef struct FPsave	FPsave;
	  typedef struct ISAConf	ISAConf;
	  typedef struct Label	Label;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/dat.h:32,37 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/dat.h:33,39
	  	ulong	sr;
	  	ulong	pc;
	  	Proc	*p;
	+ 	Mach	*m;
	  	ushort	isilock;
	  };
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/dat.h:73,85 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/dat.h:75,94
	  	uchar	regs[80];	/* floating point registers */
	  };
	  
	+ struct Confmem
	+ {
	+ 	ulong	base;
	+ 	ulong	npage;
	+ 	ulong	kbase;
	+ 	ulong	klimit;
	+ };
	+ 
	  struct Conf
	  {
	  	ulong	nmach;		/* processors */
	  	ulong	nproc;		/* processes */
	  	ulong	monitor;	/* has monitor? */
	- 	ulong	npage0;		/* total physical pages of memory */
	- 	ulong	npage1;		/* total physical pages of memory */
	+ 	Confmem	mem[4];		/* physical memory */
	  	ulong	npage;		/* total physical pages of memory */
	  	ulong	upages;		/* user page pool */
	  	ulong	nimage;		/* number of page cache image headers */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/dat.h:102,107 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/dat.h:111,117
	  	Page*	mmupdb;			/* page directory base */
	  	Page*	mmufree;		/* unused page table pages */
	  	Page*	mmuused;		/* used page table pages */
	+ 	uint	lastkmap;		/* last entry used by kmap */
	  };
	  
	  /*
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/dat.h:212,223 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/dat.h:222,233
	  };
	  
	  /*
	-  * Fake kmap
	+  * KMap the structure doesn't exist, but the functions do.
	   */
	- typedef void		KMap;
	- #define	VA(k)		((ulong)(k))
	- #define	kmap(p)		(KMap*)((p)->pa|KZERO)
	- #define	kunmap(k)
	+ typedef struct KMap		KMap;
	+ #define	VA(k)		((void*)(k))
	+ KMap*	kmap(Page*);
	+ void	kunmap(KMap*);
	  
	  struct
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/dat.h:243,248 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/dat.h:253,260
	  	int	(*intrenable)(Vctl*);
	  	int	(*intrvecno)(int);
	  	int	(*intrdisable)(int);
	+ 	void	(*introff)(void);
	+ 	void	(*intron)(void);
	  
	  	void	(*clockenable)(void);
	  	uvlong	(*fastclock)(uvlong*);
 [rsc] --rw-rw-r-- M 451989 glenda sys 18594 Nov  6 10:17 sys/src/9/pc/devarch.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devarch.c:520,525 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devarch.c:520,527
	  .intrenable=	i8259enable,
	  .intrvecno=	i8259vecno,
	  .intrdisable=	i8259disable,
	+ .intron=		i8259on,
	+ .introff=		i8259off,
	  
	  .clockenable=	i8253enable,
	  .fastclock=	i8253read,
 [rsc] --rw-rw-r-- M 451989 glenda sys 10315 Nov  6 10:17 sys/src/9/pc/devether.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devether.c:416,422 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devether.c:416,422
	  	i = sprint(buf, "#l%d: %s: %dMbps port 0x%luX irq %d",
	  		ctlrno, cards[cardno].type, ether->mbps, ether->port, ether->irq);
	  	if(ether->mem)
	- 		i += sprint(buf+i, " addr 0x%luX", PADDR(ether->mem));
	+ 		i += sprint(buf+i, " addr 0x%luX", ether->mem);
	  	if(ether->size)
	  		i += sprint(buf+i, " size 0x%luX", ether->size);
	  	i += sprint(buf+i, ": %2.2ux%2.2ux%2.2ux%2.2ux%2.2ux%2.2ux",
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devether.c:425,440 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devether.c:425,439
	  	sprint(buf+i, "\n");
	  	print(buf);
	  
	- 	if (ether->mbps >= 1000) {
	+ 	if(ether->mbps >= 1000){
	  		netifinit(ether, name, Ntypes, 512*1024);
	  		if(ether->oq == 0)
	  			ether->oq = qopen(512*1024, Qmsg, 0, 0);
	- 	} else if(ether->mbps >= 100){
	+ 	}else if(ether->mbps >= 100){
	  		netifinit(ether, name, Ntypes, 256*1024);
	  		if(ether->oq == 0)
	  			ether->oq = qopen(256*1024, Qmsg, 0, 0);
	- 	}
	- 	else{
	+ 	}else{
	  		netifinit(ether, name, Ntypes, 128*1024);
	  		if(ether->oq == 0)
	  			ether->oq = qopen(128*1024, Qmsg, 0, 0);
 [rsc] --rw-rw-r-- M 451989 glenda sys 40203 Nov  6 10:18 sys/src/9/pc/devpccard.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devpccard.c:515,520 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devpccard.c:515,521
	  	int i;
	  	uchar intl;
	  	char *p;
	+ 	void *baddrva;
	  
	  	if (initialized) 
	  		return;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devpccard.c:623,636 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devpccard.c:624,638
	  		intl = pci->intl;
	  
	  		if ((baddr = pcicfgr32(cb->pci, PciBAR0)) == 0) {
	- 			int align = (pci->did == Ricoh_478_did)? 0x10000: 0x1000;
	+ 			int size = (pci->did == Ricoh_478_did)? 0x10000: 0x1000;
	  
	- 			baddr = upamalloc(baddr, align, align);
	+ 			baddr = upaalloc(size, size);
	+ 			baddrva = vmap(baddr, size);
	  			pcicfgw32(cb->pci, PciBAR0, baddr);
	- 			cb->regs = (ulong *)KADDR(baddr);
	+ 			cb->regs = (ulong *)baddrva;
	  		}
	  		else
	- 			cb->regs = (ulong *)KADDR(upamalloc(baddr, 4096, 0));
	+ 			cb->regs = (ulong *)vmap(baddr, 4096);
	  		cb->state = SlotEmpty;
	  
	  		/* Don't really know what to do with this... */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devpccard.c:810,816 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devpccard.c:812,818
	  				continue;
	  			}
	  
	- 			bar = upamalloc(0, pci->mem[i].size, BY2PG);
	+ 			bar = upaalloc(pci->mem[i].size, BY2PG);
	  			pci->mem[i].bar = bar | (pci->mem[i].bar & 0x80);
	  			pcicfgw32(pci, PciBAR0 + i * sizeof(ulong), pci->mem[i].bar);
	  			pcicfgw32(cb->pci, PciCBMBR0 + memindex * 8, bar);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devpccard.c:834,840 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devpccard.c:836,842
	  				print("#Y%ld: WARNING: Too many memory spaces, not mapping ROM space\n",
	  					cb - cbslots);
	  			else {
	- 				pci->rom.bar = upamalloc(0, size, BY2PG);
	+ 				pci->rom.bar = upaalloc(size, BY2PG);
	  				pci->rom.size = size;
	  
	  				pcicfgw32(pci, PciEBAR0, pci->rom.bar);
 [rsc] --rw-rw-r-- M 451989 glenda sys 45676 Nov  6 10:18 sys/src/9/pc/devtv.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:557,563 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:557,563
	  		tv = &tvs[ntvs++];
	  		tv->variant = &variant[i];
	  		tv->pci = pci;
	- 		tv->bt848 = (Bt848 *)upamalloc(pci->mem[0].bar & ~0x0F, 4 * K, K);
	+ 		tv->bt848 = (Bt848 *)vmap(pci->mem[0].bar & ~0x0F, 4 * K);
	  		if (tv->bt848 == nil)
	  			panic("#V: Cannot allocate memory for Bt848");
	  		bt848 = tv->bt848;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:591,597 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:591,597
	  				panic("#V: Unsupported Hauppage board");
	  
	  			tv->bt878 = bt878 = 
	- 				(Bt848 *)upamalloc(pci878->mem[0].bar & ~0x0F, 4 * K, K);
	+ 				(Bt848 *)vmap(pci878->mem[0].bar & ~0x0F, 4 * K);
	  			if (bt878 == nil)
	  				panic("#V: Cannot allocate memory for the Bt878");
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1206,1212 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1206,1212
	  }
	  
	  static ulong *
	- riscpacked(ulong paddr, int fnum, int w, int h, int stride, ulong **lastjmp)
	+ riscpacked(ulong pa, int fnum, int w, int h, int stride, ulong **lastjmp)
	  {
	  	ulong *p, *pbase;
	  	int i;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1224,1230 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1224,1230
	  
	  	for (i = 0; i != h / 2; i++) {
	  		*p++ = riscwrite | w | riscwrite_sol | riscwrite_eol;
	- 		*p++ = paddr + i * 2 * stride;
	+ 		*p++ = pa + i * 2 * stride;
	  	}
	  
	  	*p++ = riscsync | riscsync_resync | riscsync_vro;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1235,1241 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1235,1241
	  
	  	for (i = 0; i != h / 2; i++) {
	  		*p++ = riscwrite | w | riscwrite_sol | riscwrite_eol;
	- 		*p++ = paddr + (i * 2 + 1) * stride;
	+ 		*p++ = pa + (i * 2 + 1) * stride;
	  	}
	  
	  	// reset status.  you really need two instructions ;-(.
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1248,1254 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1248,1254
	  }
	  
	  static ulong *
	- riscplanar411(ulong paddr, int fnum, int w, int h, ulong **lastjmp)
	+ riscplanar411(ulong pa, int fnum, int w, int h, ulong **lastjmp)
	  {
	  	ulong *p, *pbase, Cw, Yw, Ch;
	  	uchar *Ybase, *Cbbase, *Crbase;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1260,1266 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1260,1266
	  	assert(p);
	  
	  	Yw = w;
	- 	Ybase = (uchar *)paddr;
	+ 	Ybase = (uchar *)pa;
	  	Cw = w >> 1;
	  	Ch = h >> 1;
	  	Cbbase = Ybase + Yw * h;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1302,1308 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1302,1308
	  }
	  
	  static ulong *
	- riscplanar422(ulong paddr, int fnum, int w, int h, ulong **lastjmp)
	+ riscplanar422(ulong pa, int fnum, int w, int h, ulong **lastjmp)
	  {
	  	ulong *p, *pbase, Cw, Yw;
	  	uchar *Ybase, *Cbbase, *Crbase;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1314,1320 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1314,1320
	  	assert(p);
	  
	  	Yw = w;
	- 	Ybase = (uchar *)paddr;
	+ 	Ybase = (uchar *)pa;
	  	Cw = w >> 1;
	  	Cbbase = Ybase + Yw * h;
	  	Crbase = Cbbase + Cw * h;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1357,1363 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1357,1363
	  }
	  
	  static ulong *
	- riscaudio(ulong paddr, int nblocks, int bsize)
	+ riscaudio(ulong pa, int nblocks, int bsize)
	  {
	  	ulong *p, *pbase;
	  	int i;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1372,1378 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1372,1378
	  		*p++ = riscwrite | riscwrite_sol | riscwrite_eol | bsize | riscirq |
	  				((i & 0xf) << risclabelshift_set) | 
	  				((~i & 0xf) << risclabelshift_reset);
	- 		*p++ = paddr + i * bsize;
	+ 		*p++ = pa + i * bsize;
	  	}
	  
	  	*p++ = riscsync | riscsync_vro;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1556,1562 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1556,1562
	  }
	  
	  static void
	- vgastart(Tv *tv, ulong paddr, int stride)
	+ vgastart(Tv *tv, ulong pa, int stride)
	  {
	  	Frame *frame;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devtv.c:1568,1574 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devtv.c:1568,1574
	  	}
	  
	  	frame->fbase = nil;
	- 	frame->fstart = riscpacked(paddr, 0, ntsc_hactive * getbitspp(tv) / 8, 
	+ 	frame->fstart = riscpacked(pa, 0, ntsc_hactive * getbitspp(tv) / 8, 
	  						   ntsc_vactive, stride * getbitspp(tv) / 8, 
	  						   &frame->fjmp);
	  	*frame->fjmp = PADDR(frame->fstart);
 [rsc] --rw-rw-r-- M 451989 glenda sys 9332 Nov  6 10:18 sys/src/9/pc/devvga.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:6,11 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:6,12
	  #include "mem.h"
	  #include "dat.h"
	  #include "fns.h"
	+ #include "io.h"
	  #include "../port/error.h"
	  
	  #define	Image	IMAGE
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:16,21 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:17,23
	  
	  enum {
	  	Qdir,
	+ 	Qvgabios,
	  	Qvgactl,
	  	Qvgaovl,
	  	Qvgaovlctl,
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:23,28 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:25,31
	  
	  static Dirtab vgadir[] = {
	  	".",	{ Qdir, 0, QTDIR },		0,	0550,
	+ 	"vgabios",	{ Qvgabios, 0 },	0x100000, 0440,
	  	"vgactl",		{ Qvgactl, 0 },		0,	0660,
	  	"vgaovl",		{ Qvgaovl, 0 },		0,	0660,
	  	"vgaovlctl",	{ Qvgaovlctl, 0 },	0, 	0660,
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:40,45 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:43,49
	  	CMpalettedepth,
	  	CMpanning,
	  	CMsize,
	+ 	CMtextmode,
	  	CMtype,
	  	CMunblank,
	  };
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:56,61 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:60,66
	  	CMpalettedepth,	"palettedepth",	2,
	  	CMpanning,	"panning",	2,
	  	CMsize,		"size",		3,
	+ 	CMtextmode,	"textmode",	1,
	  	CMtype,		"type",		2,
	  	CMunblank,	"unblank",	1,
	  };
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:153,158 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:158,171
	  	case Qdir:
	  		return devdirread(c, a, n, vgadir, nelem(vgadir), devgen);
	  
	+ 	case Qvgabios:
	+ 		if(offset >= 0x100000)
	+ 			return 0;
	+ 		if(offset+n >= 0x100000)
	+ 			n = 0x100000 - offset;
	+ 		memmove(a, (uchar*)kaddr(0)+offset, n);
	+ 		return n;
	+ 
	  	case Qvgactl:
	  		scr = &vgascreen[0];
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:186,192 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:199,207
	  		len += snprint(p+len, READSTR-len, "hwaccel %s\n", hwaccel ? "on" : "off");
	  		len += snprint(p+len, READSTR-len, "hwblank %s\n", hwblank ? "on" : "off");
	  		len += snprint(p+len, READSTR-len, "panning %s\n", panning ? "on" : "off");
	- 		snprint(p+len, READSTR-len, "addr 0x%lux\n", scr->aperture);
	+ 		len += snprint(p+len, READSTR-len, "addr p 0x%lux v 0x%p size 0x%ux\n", scr->paddr, scr->vaddr, scr->apsize);
	+ 		USED(len);
	+ 
	  		n = readstr(offset, a, n, p);
	  		poperror();
	  		free(p);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:233,239 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:248,264
	  			unlock(&cursor);
	  			return;
	  		}
	- 
	+ 		if(strcmp(cb->f[1], "soft") == 0){
	+ 			lock(&cursor);
	+ 			swcursorinit();
	+ 			if(scr->cur && scr->cur->disable)
	+ 				scr->cur->disable(scr);
	+ 			scr->cur = &swcursor;
	+ 			if(scr->cur->enable)
	+ 				scr->cur->enable(scr);
	+ 			unlock(&cursor);
	+ 			return;
	+ 		}
	  		for(i = 0; vgacur[i]; i++){
	  			if(strcmp(cb->f[1], vgacur[i]->name))
	  				continue;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:261,269 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:286,296
	  		}
	  		break;
	  
	+ 	case CMtextmode:
	+ 		screeninit();
	+ 		return;
	+ 
	  	case CMsize:
	- 		if(drawhasclients())
	- 			error(Ebusy);
	  
	  		x = strtoul(cb->f[1], &p, 0);
	  		if(x == 0 || x > 2048)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:291,296 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:318,324
	  		if(screensize(x, y, z, chan))
	  			error(Egreg);
	  		vgascreenwin(scr);
	+ 		resetscreenimage();
	  		cursoron(1);
	  		return;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devvga.c:337,343 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devvga.c:365,371
	  			align = 0;
	  		else
	  			align = strtoul(cb->f[2], 0, 0);
	- 		if(screenaperture(size, align))
	+ 		if(screenaperture(size, align) < 0)
	  			error("not enough free address space");
	  		return;
	  /*	
 [rsc] --rw-rw-r-- M 451989 glenda sys 4715 Nov  6 10:18 sys/src/9/pc/dma.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/dma.c:140,149 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/dma.c:140,148
	  	 *  if this isn't kernel memory or crossing 64k boundary or above 16 meg
	  	 *  use the bounce buffer.
	  	 */
	- 	pa = PADDR(va);
	- 	if((((ulong)va)&0xF0000000) != KZERO
	- 	|| (pa&0xFFFF0000) != ((pa+len)&0xFFFF0000)
	- 	|| pa >= 16*MB) {
	+ 	if((ulong)va < KZERO 
	+ 	|| ((pa=PADDR(va))&0xFFFF0000) != ((pa+len)&0xFFFF0000)
	+ 	|| pa >= 16*MB){
	  		if(xp->bva == nil)
	  			return -1;
	  		if(len > xp->blen)
 [rsc] --rw-rw-r-- M 451989 glenda sys 13953 Nov  6 10:18 sys/src/9/pc/ether79c970.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether79c970.c:522,528 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether79c970.c:522,527
	  		ctlr->iow = io32w;
	  	}else{
	  		print("#l%d: card doesn't talk right\n", ether->ctlrno);
	- iprint("#l%d: card doesn't talk right\n", ether->ctlrno);
	  		iunlock(ctlr);
	  		return -1;
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether79c970.c:538,545 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether79c970.c:537,542
	  		break;
	  	default:
	  		print("#l%d: unknown PCnet card version %.7ux\n",
	- 			ether->ctlrno, x&0xFFFFFFF);
	- iprint("#l%d: unknown PCnet card version %.7ux\n",
	  			ether->ctlrno, x&0xFFFFFFF);
	  		iunlock(ctlr);
	  		return -1;
 [rsc] --rw-rw-r-- M 451989 glenda sys 18400 Nov  6 10:19 sys/src/9/pc/ether8139.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8139.c:243,249 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8139.c:243,249
	  
	  	ctlr = edev->ctlr;
	  	p = malloc(READSTR);
	- 	l = snprint(p, READSTR, "rcr %8.8uX\n", ctlr->rcr);
	+ 	l = snprint(p, READSTR, "rcr %#8.8ux\n", ctlr->rcr);
	  	l += snprint(p+l, READSTR-l, "ierrs %d\n", ctlr->ierrs);
	  	l += snprint(p+l, READSTR-l, "etxth %d\n", ctlr->etxth);
	  	l += snprint(p+l, READSTR-l, "taligned %d\n", ctlr->taligned);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8139.c:255,274 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8139.c:255,274
	  	ctlr->rec += csr16r(ctlr, Rec);
	  	l += snprint(p+l, READSTR-l, "rec %d\n", ctlr->rec);
	  
	- 	l += snprint(p+l, READSTR-l, "Tcr %8.8luX\n", csr32r(ctlr, Tcr));
	- 	l += snprint(p+l, READSTR-l, "Config0 %2.2uX\n", csr8r(ctlr, Config0));
	- 	l += snprint(p+l, READSTR-l, "Config1 %2.2uX\n", csr8r(ctlr, Config1));
	- 	l += snprint(p+l, READSTR-l, "Msr %2.2uX\n", csr8r(ctlr, Msr));
	- 	l += snprint(p+l, READSTR-l, "Config3 %2.2uX\n", csr8r(ctlr, Config3));
	- 	l += snprint(p+l, READSTR-l, "Config4 %2.2uX\n", csr8r(ctlr, Config4));
	+ 	l += snprint(p+l, READSTR-l, "Tcr %#8.8lux\n", csr32r(ctlr, Tcr));
	+ 	l += snprint(p+l, READSTR-l, "Config0 %#2.2ux\n", csr8r(ctlr, Config0));
	+ 	l += snprint(p+l, READSTR-l, "Config1 %#2.2ux\n", csr8r(ctlr, Config1));
	+ 	l += snprint(p+l, READSTR-l, "Msr %#2.2ux\n", csr8r(ctlr, Msr));
	+ 	l += snprint(p+l, READSTR-l, "Config3 %#2.2ux\n", csr8r(ctlr, Config3));
	+ 	l += snprint(p+l, READSTR-l, "Config4 %#2.2ux\n", csr8r(ctlr, Config4));
	  
	- 	l += snprint(p+l, READSTR-l, "Bmcr %4.4uX\n", csr16r(ctlr, Bmcr));
	- 	l += snprint(p+l, READSTR-l, "Bmsr %4.4uX\n", csr16r(ctlr, Bmsr));
	- 	l += snprint(p+l, READSTR-l, "Anar %4.4uX\n", csr16r(ctlr, Anar));
	- 	l += snprint(p+l, READSTR-l, "Anlpar %4.4uX\n", csr16r(ctlr, Anlpar));
	- 	l += snprint(p+l, READSTR-l, "Aner %4.4uX\n", csr16r(ctlr, Aner));
	- 	l += snprint(p+l, READSTR-l, "Nwaytr %4.4uX\n", csr16r(ctlr, Nwaytr));
	- 	snprint(p+l, READSTR-l, "Cscr %4.4uX\n", csr16r(ctlr, Cscr));
	+ 	l += snprint(p+l, READSTR-l, "Bmcr %#4.4ux\n", csr16r(ctlr, Bmcr));
	+ 	l += snprint(p+l, READSTR-l, "Bmsr %#4.4ux\n", csr16r(ctlr, Bmsr));
	+ 	l += snprint(p+l, READSTR-l, "Anar %#4.4ux\n", csr16r(ctlr, Anar));
	+ 	l += snprint(p+l, READSTR-l, "Anlpar %#4.4ux\n", csr16r(ctlr, Anlpar));
	+ 	l += snprint(p+l, READSTR-l, "Aner %#4.4ux\n", csr16r(ctlr, Aner));
	+ 	l += snprint(p+l, READSTR-l, "Nwaytr %#4.4ux\n", csr16r(ctlr, Nwaytr));
	+ 	snprint(p+l, READSTR-l, "Cscr %#4.4ux\n", csr16r(ctlr, Cscr));
	  	n = readstr(offset, a, n, p);
	  	free(p);
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8139.c:589,595 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8139.c:589,595
	  		 * other than try to reinitialise the chip?
	  		 */
	  		if((isr & (Serr|Timerbit)) != 0){
	- 			iprint("rtl8139interrupt: imr %4.4uX isr %4.4uX\n",
	+ 			iprint("rtl8139interrupt: imr %#4.4ux isr %#4.4ux\n",
	  				csr16r(ctlr, Imr), isr);
	  			if(isr & Timerbit)
	  				csr32w(ctlr, TimerInt, 0);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8139.c:621,627 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8139.c:621,627
	  			continue;
	  
	  		if(ioalloc(port, p->mem[0].size, 0, "rtl8139") < 0){
	- 			print("rtl8139: port 0x%uX in use\n", port);
	+ 			print("rtl8139: port %#ux in use\n", port);
	  			continue;
	  		}
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 32294 Nov  6 10:19 sys/src/9/pc/ether82543gc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82543gc.c:1243,1249 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82543gc.c:1243,1250
	  static void
	  gc82543pci(void)
	  {
	- 	int port, cls;
	+ 	int cls;
	+ 	void *mem;
	  	Pcidev *p;
	  	Ctlr *ctlr;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82543gc.c:1262,1269 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82543gc.c:1263,1270
	  			break;
	  		}
	  
	- 		port = upamalloc(p->mem[0].bar & ~0x0F, p->mem[0].size, 0);
	- 		if(port == 0){
	+ 		mem = vmap(p->mem[0].bar & ~0x0F, p->mem[0].size);
	+ 		if(mem == 0){
	  			print("gc82543: can't map %8.8luX\n", p->mem[0].bar);
	  			continue;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82543gc.c:1280,1290 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82543gc.c:1281,1290
	  					cls*4);
	  		}
	  		ctlr = malloc(sizeof(Ctlr));
	- 		ctlr->port = port;
	+ 		ctlr->port = p->mem[0].bar & ~0x0F;
	  		ctlr->pcidev = p;
	  		ctlr->id = (p->did<<16)|p->vid;
	- 
	- 		ctlr->nic = KADDR(ctlr->port);
	+ 		ctlr->nic = mem;
	  
	  		if(gc82543reset(ctlr)){
	  			free(ctlr);
 [rsc] --rw-rw-r-- M 451989 glenda sys 30107 Nov  6 10:19 sys/src/9/pc/ether82557.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82557.c:290,296 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82557.c:290,296
	  	if(timeo >= 100){
	  		ctlr->command = -1;
	  		iunlock(&ctlr->rlock);
	- 		iprint("i82557: command 0x%uX %uX timeout\n", c, v);
	+ 		iprint("i82557: command %#ux %#ux timeout\n", c, v);
	  		return;
	  	}
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82557.c:462,468 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82557.c:462,468
	  	for(i = 0; i < (1<<ctlr->eepromsz); i++){
	  		if(i && ((i & 0x07) == 0))
	  			len += snprint(p+len, READSTR-len, "\n       ");
	- 		len += snprint(p+len, READSTR-len, " %4.4uX", ctlr->eeprom[i]);
	+ 		len += snprint(p+len, READSTR-len, " %4.4ux", ctlr->eeprom[i]);
	  	}
	  
	  	if((ctlr->eeprom[6] & 0x1F00) && !(ctlr->eeprom[6] & 0x8000)){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82557.c:471,477 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82557.c:471,477
	  		for(i = 0; i < 6; i++){
	  			static int miir(Ctlr*, int, int);
	  
	- 			len += snprint(p+len, READSTR-len, " %4.4uX",
	+ 			len += snprint(p+len, READSTR-len, " %4.4ux",
	  				miir(ctlr, phyaddr, i));
	  		}
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82557.c:523,529 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82557.c:523,529
	  			ctlr->action = 0;
	  		}
	  		else{
	- 			print("#l%d: action 0x%uX\n", ether->ctlrno, ctlr->action);
	+ 			print("#l%d: action %#ux\n", ether->ctlrno, ctlr->action);
	  			ctlr->action = 0;
	  			break;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82557.c:630,636 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82557.c:630,636
	  			pbp = nil;
	  			count = rfd->count & 0x3FFF;
	  			if((count < ETHERMAXTU/4) && (pbp = iallocb(count))){
	- 				memmove(pbp->rp, bp->rp+sizeof(Rfd)-sizeof(rfd->data), count);
	+ 				memmove(pbp->rp, bp->rp+offsetof(Rfd, data[0]), count);
	  				pbp->wp = pbp->rp + count;
	  
	  				rfd->count = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82557.c:637,643 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82557.c:637,643
	  				rfd->field = 0;
	  			}
	  			else if(xbp = rfdalloc(rfd->link)){
	- 				bp->rp += sizeof(Rfd)-sizeof(rfd->data);
	+ 				bp->rp += offsetof(Rfd, data[0]);
	  				bp->wp = bp->rp + count;
	  
	  				xbp->next = bp->next;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82557.c:748,754 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82557.c:748,754
	  		}
	  
	  		if(status & (StatCX|StatFR|StatCNA|StatRNR|StatMDI|StatSWI))
	- 			panic("#l%d: status %uX\n", ether->ctlrno, status);
	+ 			panic("#l%d: status %#ux\n", ether->ctlrno, status);
	  	}
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82557.c:955,961 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82557.c:955,961
	  		 */
	  		port = p->mem[1].bar & ~0x01;
	  		if(ioalloc(port, p->mem[1].size, 0, "i82557") < 0){
	- 			print("i82557: port 0x%uX in use\n", port);
	+ 			print("i82557: port %#ux in use\n", port);
	  			continue;
	  		}
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82557.c:997,1003 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82557.c:997,1003
	  		oui <<= 6;
	  		x = miir(ctlr, i, 3);
	  		oui |= x>>10;
	- 		//print("phy%d: oui %uX reg1 %uX\n", i, oui, miir(ctlr, i, 1));
	+ 		//print("phy%d: oui %#ux reg1 %#ux\n", i, oui, miir(ctlr, i, 1));
	  
	  		ctlr->eeprom[6] = i;
	  		if(oui == 0xAA00)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether82557.c:1093,1099 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether82557.c:1093,1099
	  		sum += x;
	  	}
	  	if(sum != 0xBABA)
	- 		print("#l%d: EEPROM checksum - 0x%4.4uX\n", ether->ctlrno, sum);
	+ 		print("#l%d: EEPROM checksum - %#4.4ux\n", ether->ctlrno, sum);
	  
	  	/*
	  	 * Eeprom[6] indicates whether there is a PHY and whether
 [rsc] --rw-rw-r-- M 451989 glenda sys 17702 Nov  6 10:19 sys/src/9/pc/ether8390.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8390.c:400,406 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8390.c:400,406
	  		 */
	  		if(hdr.next < ctlr->pstart || hdr.next >= ctlr->pstop
	  		  || len < 60 || len > sizeof(Etherpkt)){
	- 			print("dp8390: H#%2.2ux#%2.2ux#%2.2ux#%2.2ux,%lud\n",
	+ 			print("dp8390: H%2.2ux+%2.2ux+%2.2ux+%2.2ux,%lud\n",
	  				hdr.status, hdr.next, hdr.len0, hdr.len1, len);
	  			regw(ctlr, Cr, Page0|RdABORT|Stp);
	  			ringinit(ctlr);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8390.c:588,594 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8390.c:588,594
	  		if(isr & (Txe|Ptx)){
	  			r = regr(ctlr, Tsr);
	  			if((isr & Txe) && (r & (Cdh|Fu|Crs|Abt))){
	- 				print("dp8390: Tsr#%2.2ux|", r);
	+ 				print("dp8390: Tsr %#2.2ux", r);
	  				ether->oerrs++;
	  			}
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8390.c:686,692 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8390.c:686,692
	  	if(reverse[1] == 0){
	  		for(i = 0; i < 64; i++)
	  			reverse[i] = ((i&1)<<5) | ((i&2)<<3) | ((i&4)<<1)
	- 					| ((i&8)>>1) | ((i&16)>>3) | ((i&32)>>5);
	+ 				   | ((i&8)>>1) | ((i&16)>>3) | ((i&32)>>5);
	  	}
	  
	  	/*
 [rsc] --rw-rw-r-- M 451989 glenda sys 48733 Nov  6 10:19 sys/src/9/pc/etherelnk3.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherelnk3.c:1485,1499 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherelnk3.c:1485,1499
	  			break;
	  		case 0x5157:
	  			ctlr->eepromcmd = EepromRead8bRegister;
	- 			ctlr->cbfnpa = upamalloc(p->mem[2].bar, p->mem[2].size, 0);
	+ 			ctlr->cbfnpa = p->mem[2].bar&~0x0F;
	+ 			ctlr->cbfn = vmap(p->mem[2].bar&~0x0F, p->mem[2].size);
	  			break;
	  		case 0x6056:
	  			ctlr->eepromcmd = EepromReadOffRegister;
	- 			ctlr->cbfnpa = upamalloc(p->mem[2].bar, p->mem[2].size, 0);
	+ 			ctlr->cbfnpa = p->mem[2].bar&~0x0F;
	+ 			ctlr->cbfn = vmap(p->mem[2].bar&~0x0F, p->mem[2].size);
	  			break;
	  		}
	- 		if(ctlr->cbfnpa != 0)
	- 			ctlr->cbfn = KADDR(ctlr->cbfnpa);
	  		pcisetbme(p);
	  	}
	  }
 [rsc] --rw-rw-r-- M 451989 jmk sys 44431 Nov  6 10:19 sys/src/9/pc/etherigbe.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherigbe.c:439,445 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherigbe.c:439,445
	  
	  typedef struct Ctlr Ctlr;
	  typedef struct Ctlr {
	- 	int	port;
	+ 	ulong	port;
	  	Pcidev*	pcidev;
	  	Ctlr*	next;
	  	int	active;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherigbe.c:1468,1474 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherigbe.c:1468,1475
	  		ctlr->mii = nil;
	  		return -1;
	  	}
	- 	print("oui %X phyno %d\n", phy->oui, phy->phyno);
	+ 	USED(phy);
	+ 	// print("oui %X phyno %d\n", phy->oui, phy->phyno);
	  
	  	/*
	  	 * 8254X-specific PHY registers not in 802.3:
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherigbe.c:1848,1857 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherigbe.c:1849,1859
	  static void
	  igbepci(void)
	  {
	- 	int port, cls;
	+ 	int cls;
	  	Pcidev *p;
	  	Ctlr *ctlr;
	- 
	+ 	void *mem;
	+ 	
	  	p = nil;
	  	while(p = pcimatch(p, 0, 0)){
	  		if(p->ccrb != 0x02 || p->ccru != 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherigbe.c:1874,1881 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherigbe.c:1876,1883
	  			break;
	  		}
	  
	- 		port = upamalloc(p->mem[0].bar & ~0x0F, p->mem[0].size, 0);
	- 		if(port == 0){
	+ 		mem = vmap(p->mem[0].bar & ~0x0F, p->mem[0].size);
	+ 		if(mem == nil){
	  			print("igbe: can't map %8.8luX\n", p->mem[0].bar);
	  			continue;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherigbe.c:1893,1903 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherigbe.c:1895,1905
	  				break;
	  		}
	  		ctlr = malloc(sizeof(Ctlr));
	- 		ctlr->port = port;
	+ 		ctlr->port = p->mem[0].bar & ~0x0F;
	  		ctlr->pcidev = p;
	  		ctlr->id = (p->did<<16)|p->vid;
	  		ctlr->cls = cls*4;
	- 		ctlr->nic = KADDR(ctlr->port);
	+ 		ctlr->nic = mem;
	  
	  		if(igbereset(ctlr)){
	  			free(ctlr);
 [rsc] --rw-rw-r-- M 451989 glenda sys 3747 Nov  6 10:19 sys/src/9/pc/etherwavelan.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherwavelan.c:87,92 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherwavelan.c:87,93
	  	int did;
	  } wavelanpci[] = {
	  	0x1260, 0x3873,	/* Intersil Prism2.5 */
	+ 	0x1737,	0x0019,	/* Linksys WPC-11 untested */
	  };
	  
	  static Ctlr *ctlrhead, *ctlrtail;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherwavelan.c:95,101 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherwavelan.c:96,102
	  wavelanpciscan(void)
	  {
	  	int i;
	- 	ulong pa;
	+ 	void *mem;
	  	Pcidev *p;
	  	Ctlr *ctlr;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherwavelan.c:117,129 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherwavelan.c:118,130
	  
	  		ctlr = malloc(sizeof(Ctlr));
	  		ctlr->pcidev = p;
	- 		pa = upamalloc(p->mem[0].bar&~0xF, p->mem[0].size, 0);
	- 		if(pa == 0){
	- 			print("wavelanpci: %.4ux %.4ux: upamalloc 0x%.8lux %d failed\n", p->vid, p->did, p->mem[0].bar&~0xF, p->mem[0].size);
	+ 		mem = vmap(p->mem[0].bar&~0xF, p->mem[0].size);
	+ 		if(mem == nil){
	+ 			print("wavelanpci: %.4ux %.4ux: vmap 0x%.8lux %d failed\n", p->vid, p->did, p->mem[0].bar&~0xF, p->mem[0].size);
	  			free(ctlr);
	  			continue;
	  		}
	- 		ctlr->mmb = (ushort*)KADDR(pa);
	+ 		ctlr->mmb = mem;
	  		if(ctlrhead != nil)
	  			ctlrtail->next = ctlr;
	  		else
 [rsc] --rw-rw-r-- M 451989 glenda sys 4461 Nov  6 10:19 sys/src/9/pc/fns.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/fns.h:3,11 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/fns.h:3,9
	  void	aamloop(int);
	  Dirtab*	addarchfile(char*, int, long(*)(Chan*,void*,long,vlong), long(*)(Chan*,void*,long,vlong));
	  void	archinit(void);
	- void	bootargs(ulong);
	- int	cistrcmp(char*, char*);
	- int	cistrncmp(char*, char*, int);
	+ void	bootargs(void*);
	  void	clockintr(Ureg*, void*);
	  void	(*coherence)(void);
	  void	cpuid(char*, int*, int*);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/fns.h:46,56 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/fns.h:44,56
	  void	i8253link(void);
	  uvlong	i8253read(uvlong*);
	  void	i8253timerset(uvlong);
	+ int	i8259disable(int);
	+ int	i8259enable(Vctl*);
	  void	i8259init(void);
	  int	i8259isr(int);
	- int	i8259enable(Vctl*);
	+ void	i8259on(void);
	+ void	i8259off(void);
	  int	i8259vecno(int);
	- int	i8259disable(int);
	  void	idle(void);
	  void	idlehands(void);
	  int	inb(int);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/fns.h:61,66 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/fns.h:61,69
	  void	insl(int, void*, int);
	  int	intrdisable(int, void (*)(Ureg *, void *), void*, int, char*);
	  void	intrenable(int, void (*)(Ureg*, void*), void*, int, char*);
	+ void	introff(void);
	+ void	intron(void);
	+ void	invlpg(ulong);
	  void	iofree(int);
	  void	ioinit(void);
	  int	iounused(int, int);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/fns.h:68,73 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/fns.h:71,77
	  int	ioreserve(int, int, int, char*);
	  int	iprint(char*, ...);
	  int	isaconfig(char*, int, ISAConf*);
	+ void*	kaddr(ulong);
	  void	kbdenable(void);
	  void	kbdinit(void);
	  #define	kmapinval()
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/fns.h:82,91 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/fns.h:86,94
	  void	mb386(void);
	  void	mb586(void);
	  void	meminit(void);
	+ void	memorysummary(void);
	  #define mmuflushtlb(pdb) putcr3(pdb)
	  void	mmuinit(void);
	- ulong	mmukmap(ulong, ulong, int);
	- int	mmukmapsync(ulong);
	  ulong*	mmuwalk(ulong*, ulong, int, int);
	  uchar	nvramread(int);
	  void	nvramwrite(int, uchar);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/fns.h:95,100 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/fns.h:98,104
	  void	outss(int, void*, int);
	  void	outl(int, ulong);
	  void	outsl(int, void*, int);
	+ ulong	paddr(void*);
	  int	pciscan(int, Pcidev**);
	  ulong	pcibarsize(Pcidev*, int);
	  int	pcicfgr8(Pcidev*, int);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/fns.h:122,139 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/fns.h:126,149
	  void	pcmspecialclose(int);
	  void	(*_pcmspecialclose)(int);
	  void	pcmunmap(int, PCMmap*);
	+ int	pdbmap(ulong*, ulong, ulong, int);
	  void	procrestore(Proc*);
	  void	procsave(Proc*);
	  void	procsetup(Proc*);
	  void	putcr3(ulong);
	  void	putcr4(ulong);
	+ void*	rampage(void);
	  void	rdmsr(int, vlong*);
	+ void	realmode(Ureg*);
	  void	screeninit(void);
	  void	(*screenputs)(char*, int);
	  void	syncclock(void);
	+ void*	tmpmap(Page*);
	+ void	tmpunmap(void*);
	  void	touser(void*);
	  void	trapenable(int, void (*)(Ureg*, void*), void*, char*);
	  void	trapinit(void);
	+ void	trapinit0(void);
	  int	tas(void*);
	  uvlong	tscticks(uvlong*);
	  ulong	umbmalloc(ulong, int, int);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/fns.h:140,154 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/fns.h:150,168
	  void	umbfree(ulong, int);
	  ulong	umbrwmalloc(ulong, int, int);
	  void	umbrwfree(ulong, int);
	- ulong	upamalloc(ulong, int, int);
	+ ulong	upaalloc(int, int);
	  void	upafree(ulong, int);
	+ void	upareserve(ulong, int);
	  #define	userureg(ur) (((ur)->cs & 0xFFFF) == UESEL)
	  void	vectortable(void);
	+ void*	vmap(ulong, int);
	+ int	vmapsync(ulong);
	+ void	vunmap(void*, int);
	  void	wrmsr(int, vlong);
	  int	xchgw(ushort*, int);
	  
	  #define	waserror()	(up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
	- #define KADDR(a)	((void*)((ulong)(a)|KZERO))
	- #define PADDR(a)	((ulong)(a)&~KZERO)
	+ #define	KADDR(a)	kaddr(a)
	+ #define PADDR(a)	paddr((void*)(a))
	  
	  #define	dcflush(a, b)
 [rsc] --rw-rw-r-- M 451989 glenda sys 4586 Nov  6 10:19 sys/src/9/pc/i8259.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/i8259.c:197,199 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/i8259.c:197,214
	  	iunlock(&i8259lock);
	  	return 0;
	  }
	+ 
	+ void
	+ i8259on(void)
	+ {
	+ 	outb(Int0aux, i8259mask&0xFF);
	+ 	outb(Int1aux, (i8259mask>>8)&0xFF);
	+ }
	+ 
	+ void
	+ i8259off(void)
	+ {
	+ 	outb(Int0aux, 0xFF);
	+ 	outb(Int1aux, 0xFF);
	+ }
	+ 
 [rsc] --rw-rw-r-- M 451989 glenda sys 28347 Nov  6 10:20 sys/src/9/pc/l.s
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:1,4 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:1,6
	  #include "mem.h"
	+ #include "/sys/src/boot/pc/x16.h"
	+ #undef DELAY
	  
	  #define PADDR(a)	((a) & ~KZERO)
	  #define KADDR(a)	(KZERO|(a))
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:13,18 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:15,21
	  #define RDTSC 		BYTE $0x0F; BYTE $0x31	/* RDTSC, result in AX/DX (lo/hi) */
	  #define RDMSR		BYTE $0x0F; BYTE $0x32	/* RDMSR, result in AX/DX (lo/hi) */
	  #define HLT		BYTE $0xF4
	+ #define INVLPG	BYTE $0x0F; BYTE $0x01; BYTE $0x39	/* INVLPG (%ecx) */
	  
	  /*
	   * Macros for calculating offsets within the page directory base
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:27,34 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:30,37
	   * 9load currently sets up the mmu, however the first 16MB of memory is identity
	   * mapped, so behave as if the mmu was not setup
	   */
	- TEXT _start0x80100020(SB), $0
	- 	MOVL	$_start0x00100020(SB), AX
	+ TEXT _startKADDR(SB), $0
	+ 	MOVL	$_startPADDR(SB), AX
	  	ANDL	$~KZERO, AX
	  	JMP*	AX
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:40,49 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:43,52
	  	LONG	$0x00010003			/* flags */
	  	LONG	$-(0x1BADB002 + 0x00010003)	/* checksum */
	  	LONG	$_multibootheader-KZERO(SB)	/* header_addr */
	- 	LONG	$_start0x80100020-KZERO(SB)	/* load_addr */
	+ 	LONG	$_startKADDR-KZERO(SB)		/* load_addr */
	  	LONG	$edata-KZERO(SB)		/* load_end_addr */
	  	LONG	$end-KZERO(SB)			/* bss_end_addr */
	- 	LONG	$_start0x80100020-KZERO(SB)	/* entry_addr */
	+ 	LONG	$_startKADDR-KZERO(SB)		/* entry_addr */
	  	LONG	$0				/* mode_type */
	  	LONG	$0				/* width */
	  	LONG	$0				/* height */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:51,57 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:54,60
	  
	  /*
	   * In protected mode with paging turned off and segment registers setup to linear map all memory.
	-  * Entered via a jump to 0x00100020, the physical address of the virtual kernel entry point of 0x80100020
	+  * Entered via a jump to PADDR(entry), the physical address of the virtual kernel entry point of KADDR(entry)
	   * Make the basic page tables for processor 0. Four pages are needed for the basic set:
	   * a page directory, a page table for mapping the first 4MB of physical memory to KZERO,
	   * and virtual and physical pages for mapping the Mach structure.
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:60,66 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:63,69
	   * identity mapping is removed once the MMU is going and the JMP has been made
	   * to virtual memory.
	   */
	- TEXT _start0x00100020(SB), $0
	+ TEXT _startPADDR(SB), $0
	  	CLI					/* make sure interrupts are off */
	  
	  	/* set up the gdt so we have sane plan 9 style gdts. */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:109,118 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:112,132
	   *  that's needed as we start executing in physical addresses. 
	   */
	  TEXT tgdtptr(SB), $0
	- 
	  	WORD	$(3*8)
	  	LONG	$tgdt-KZERO(SB)
	  
	+ TEXT m0rgdtptr(SB), $0
	+ 	WORD	$(NGDT*8-1)
	+ 	LONG	$(CPU0GDT-KZERO)
	+ 
	+ TEXT m0gdtptr(SB), $0
	+ 	WORD	$(NGDT*8-1)
	+ 	LONG	$CPU0GDT
	+ 
	+ TEXT m0idtptr(SB), $0
	+ 	WORD $(256*8-1)
	+ 	LONG $IDTADDR
	+ 
	  TEXT mode32bit(SB), $0
	  	/* At this point, the GDT setup is done. */
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:126,132 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:140,146
	  
	  	MOVL	$PADDR(CPU0PDB), AX
	  	ADDL	$PDO(KZERO), AX			/* page directory offset for KZERO */
	- 	MOVL	$PADDR(CPU0PTE), (AX)		/* PTE's for 0x80000000 */
	+ 	MOVL	$PADDR(CPU0PTE), (AX)		/* PTE's for KZERO */
	  	MOVL	$(PTEWRITE|PTEVALID), BX	/* page permissions */
	  	ORL	BX, (AX)
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:212,217 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:226,459
	  	JMP	_idle
	  
	  /*
	+  * Save registers.
	+  */
	+ TEXT saveregs(SB), $0
	+ 	/* appease 8l */
	+ 	SUBL $32, SP
	+ 	POPL AX
	+ 	POPL AX
	+ 	POPL AX
	+ 	POPL AX
	+ 	POPL AX
	+ 	POPL AX
	+ 	POPL AX
	+ 	POPL AX
	+ 	
	+ 	PUSHL	AX
	+ 	PUSHL	BX
	+ 	PUSHL	CX
	+ 	PUSHL	DX
	+ 	PUSHL	BP
	+ 	PUSHL	DI
	+ 	PUSHL	SI
	+ 	PUSHFL
	+ 
	+ 	XCHGL	32(SP), AX	/* swap return PC and saved flags */
	+ 	XCHGL	0(SP), AX
	+ 	XCHGL	32(SP), AX
	+ 	RET
	+ 
	+ TEXT restoreregs(SB), $0
	+ 	/* appease 8l */
	+ 	PUSHL	AX
	+ 	PUSHL	AX
	+ 	PUSHL	AX
	+ 	PUSHL	AX
	+ 	PUSHL	AX
	+ 	PUSHL	AX
	+ 	PUSHL	AX
	+ 	PUSHL	AX
	+ 	ADDL	$32, SP
	+ 	
	+ 	XCHGL	32(SP), AX	/* swap return PC and saved flags */
	+ 	XCHGL	0(SP), AX
	+ 	XCHGL	32(SP), AX
	+ 
	+ 	POPFL
	+ 	POPL	SI
	+ 	POPL	DI
	+ 	POPL	BP
	+ 	POPL	DX
	+ 	POPL	CX
	+ 	POPL	BX
	+ 	POPL	AX
	+ 	RET
	+ 
	+ /*
	+  * Assumed to be in protected mode at time of call.
	+  * Switch to real mode, execute an interrupt, and
	+  * then switch back to protected mode.  
	+  *
	+  * Assumes:
	+  *
	+  *	- no device interrupts are going to come in
	+  *	- 0-16MB is identity mapped in page tables
	+  *	- realmode() has copied us down from 0x100000 to 0x8000
	+  *	- can use code segment 0x0800 in real mode
	+  *		to get at l.s code
	+  *	- l.s code is less than 1 page
	+  */
	+ #define RELOC	(RMCODE-KTZERO)
	+ 
	+ TEXT realmodeidtptr(SB), $0
	+ 	WORD	$(4*256-1)
	+ 	LONG	$0
	+ 
	+ TEXT realmode0(SB), $0
	+ 	CALL	saveregs(SB)
	+ 
	+ 	/* switch to low code address */
	+ 	LEAL	physcode-KZERO(SB), AX
	+ 	JMP *AX
	+ 
	+ TEXT physcode(SB), $0
	+ 
	+ 	/* switch to low stack */
	+ 	MOVL	SP, AX
	+ 	MOVL	$0x7C00, SP
	+ 	PUSHL	AX
	+ 
	+ 	/* change gdt to physical pointer */
	+ 	MOVL	m0rgdtptr-KZERO(SB), GDTR
	+ 
	+ 	/* load IDT with real-mode version*/
	+ 	MOVL	realmodeidtptr-KZERO(SB), IDTR
	+ 
	+ 	/* edit INT $0x00 instruction below */
	+ 	MOVL	$(RMUADDR-KZERO+48), AX	/* &rmu.trap */
	+ 	MOVL	(AX), AX
	+ 	MOVB	AX, realmodeintrinst+(-KZERO+1+RELOC)(SB)
	+ 
	+ 	/* disable paging */
	+ 	MOVL	CR0, AX
	+ 	ANDL	$0x7FFFFFFF, AX
	+ 	MOVL	AX, CR0
	+ 	/* JMP .+2 to clear prefetch queue*/
	+ 	BYTE $0xEB; BYTE $0x00
	+ 
	+ 	/* jump to 16-bit code segment */
	+ /*	JMPFAR	SELECTOR(KESEG16, SELGDT, 0):$again16bit(SB) /**/
	+ 	 BYTE	$0xEA
	+ 	 LONG	$again16bit-KZERO(SB)
	+ 	 WORD	$SELECTOR(KESEG16, SELGDT, 0)
	+ 
	+ TEXT again16bit(SB), $0
	+ 	/*
	+ 	 * Now in 16-bit compatibility mode.
	+ 	 * These are 32-bit instructions being interpreted
	+ 	 * as 16-bit instructions.  I'm being lazy and
	+ 	 * not using the macros because I know when
	+ 	 * the 16- and 32-bit instructions look the same
	+ 	 * or close enough.
	+ 	 */
	+ 
	+ 	/* disable protected mode and jump to real mode cs */
	+ 	OPSIZE; MOVL CR0, AX
	+ 	OPSIZE; XORL BX, BX
	+ 	OPSIZE; INCL BX
	+ 	OPSIZE; XORL BX, AX
	+ 	OPSIZE; MOVL AX, CR0
	+ 
	+ 	/* JMPFAR 0x0800:now16real */
	+ 	 BYTE $0xEA
	+ 	 WORD	$now16real-KZERO(SB)
	+ 	 WORD	$0x0800
	+ 
	+ TEXT now16real(SB), $0
	+ 	/* copy the registers for the bios call */
	+ 	LWI(0x0000, rAX)
	+ 	MOVW	AX,SS
	+ 	LWI(RMUADDR, rBP)
	+ 	
	+ 	/* offsets are in Ureg */
	+ 	LXW(44, xBP, rAX)
	+ 	MOVW	AX, DS
	+ 	LXW(40, xBP, rAX)
	+ 	MOVW	AX, ES
	+ 
	+ 	OPSIZE; LXW(0, xBP, rDI)
	+ 	OPSIZE; LXW(4, xBP, rSI)
	+ 	OPSIZE; LXW(16, xBP, rBX)
	+ 	OPSIZE; LXW(20, xBP, rDX)
	+ 	OPSIZE; LXW(24, xBP, rCX)
	+ 	OPSIZE; LXW(28, xBP, rAX)
	+ 
	+ 	CLC
	+ 
	+ TEXT realmodeintrinst(SB), $0
	+ 	INT $0x00
	+ 
	+ 	/* save the registers after the call */
	+ 
	+ 	LWI(0x7bfc, rSP)
	+ 	OPSIZE; PUSHFL
	+ 	OPSIZE; PUSHL AX
	+ 
	+ 	LWI(0, rAX)
	+ 	MOVW	AX,SS
	+ 	LWI(RMUADDR, rBP)
	+ 	
	+ 	OPSIZE; SXW(rDI, 0, xBP)
	+ 	OPSIZE; SXW(rSI, 4, xBP)
	+ 	OPSIZE; SXW(rBX, 16, xBP)
	+ 	OPSIZE; SXW(rDX, 20, xBP)
	+ 	OPSIZE; SXW(rCX, 24, xBP)
	+ 	OPSIZE; POPL AX
	+ 	OPSIZE; SXW(rAX, 28, xBP)
	+ 
	+ 	MOVW	DS, AX
	+ 	OPSIZE; SXW(rAX, 44, xBP)
	+ 	MOVW	ES, AX
	+ 	OPSIZE; SXW(rAX, 40, xBP)
	+ 
	+ 	OPSIZE; POPL AX
	+ 	OPSIZE; SXW(rAX, 64, xBP)	/* flags */
	+ 
	+ 	/* re-enter protected mode and jump to 32-bit code */
	+ 	OPSIZE; MOVL $1, AX
	+ 	OPSIZE; MOVL AX, CR0
	+ 	
	+ /*	JMPFAR	SELECTOR(KESEG, SELGDT, 0):$again32bit(SB) /**/
	+ 	 OPSIZE
	+ 	 BYTE $0xEA
	+ 	 LONG	$again32bit-KZERO(SB)
	+ 	 WORD	$SELECTOR(KESEG, SELGDT, 0)
	+ 
	+ TEXT again32bit(SB), $0
	+ 	MOVW	$SELECTOR(KDSEG, SELGDT, 0),AX
	+ 	MOVW	AX,DS
	+ 	MOVW	AX,SS
	+ 	MOVW	AX,ES
	+ 	MOVW	AX,FS
	+ 	MOVW	AX,GS
	+ 
	+ 	/* enable paging and jump to kzero-address code */
	+ 	MOVL	CR0, AX
	+ 	ORL	$0x80000000, AX
	+ 	MOVL	AX, CR0
	+ 	LEAL	again32kzero(SB), AX
	+ 	JMP*	AX
	+ 
	+ TEXT again32kzero(SB), $0
	+ 	/* breathe a sigh of relief - back in 32-bit protected mode */
	+ 
	+ 	/* switch to old stack */	
	+ 	PUSHL	AX	/* match popl below for 8l */
	+ 	MOVL	$0x7BFC, SP
	+ 	POPL	SP
	+ 
	+ 	/* restore idt */
	+ 	MOVL	m0idtptr(SB),IDTR
	+ 
	+ 	/* restore gdt */
	+ 	MOVL	m0gdtptr(SB), GDTR
	+ 
	+ 	CALL	restoreregs(SB)
	+ 	RET
	+ 
	+ /*
	+ /*
	   * Port I/O.
	   *	in[bsl]		input a byte|short|long
	   *	ins[bsl]	input a string of bytes|shorts|longs
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:347,352 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:589,600
	  	MOVL	AX, CR4
	  	RET
	  
	+ TEXT invlpg(SB), $0
	+ 	/* 486+ only */
	+ 	MOVL	va+0(FP), CX
	+ 	INVLPG
	+ 	RET
	+ 
	  TEXT _cycles(SB), $0				/* time stamp counter */
	  	RDTSC
	  	MOVL	vlong+0(FP), CX			/* &vlong */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/l.s:442,462 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/l.s:690,710
	   * FNxxx variations) so WAIT instructions must be explicitly placed in the
	   * code as necessary.
	   */
	- #define	FPOFF(l)							;\
	- 	MOVL	CR0, AX 					 	;\
	- 	ANDL	$0xC, AX			/* EM, TS */	 	;\
	- 	CMPL	AX, $0x8					 	;\
	- 	JEQ 	l						 	;\
	- 	WAIT							 	;\
	- l:								 	;\
	- 	MOVL	CR0, AX							;\
	- 	ANDL	$~0x4, AX			/* EM=0 */		;\
	- 	ORL	$0x28, AX			/* NE=1, TS=1 */	;\
	+ #define	FPOFF(l)						 ;\
	+ 	MOVL	CR0, AX 					 ;\
	+ 	ANDL	$0xC, AX			/* EM, TS */	 ;\
	+ 	CMPL	AX, $0x8					 ;\
	+ 	JEQ 	l						 ;\
	+ 	WAIT							 ;\
	+ l:								 ;\
	+ 	MOVL	CR0, AX						 ;\
	+ 	ANDL	$~0x4, AX			/* EM=0 */	 ;\
	+ 	ORL	$0x28, AX			/* NE=1, TS=1 */ ;\
	  	MOVL	AX, CR0
	  
	- #define	FPON								;\
	- 	MOVL	CR0, AX							;\
	- 	ANDL	$~0xC, AX			/* EM=0, TS=0 */	;\
	+ #define	FPON							 ;\
	+ 	MOVL	CR0, AX						 ;\
	+ 	ANDL	$~0xC, AX			/* EM=0, TS=0 */ ;\
	  	MOVL	AX, CR0
	  	
	  TEXT fpoff(SB), $0				/* disable */
 [rsc] --rw-rw-r-- M 451989 glenda sys 15224 Nov  6 10:20 sys/src/9/pc/main.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:29,34 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:29,35
	  char *confval[MAXCONF];
	  int nconf;
	  uchar *sp;	/* user stack of init proc */
	+ int delaylink;
	  
	  static void
	  options(void)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:69,74 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:70,76
	  	}
	  }
	  
	+ void mmuinit0(void);
	  void
	  main(void)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:81,86 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:83,91
	  
	  	print("\nPlan 9\n");
	  
	+ 	trapinit0();
	+ 	mmuinit0();
	+ 
	  	kbdinit();
	  	i8253init();
	  	cpuidentify();
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:101,107 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:106,116
	  		arch->clockenable();
	  	procinit0();
	  	initseg();
	- 	links();
	+ 	if(delaylink){
	+ 		bootlinks();
	+ 		pcimatch(0, 0, 0);
	+ 	}else
	+ 		links();
	  	conf.monitor = 1;
	  	chandevreset();
	  	pageinit();
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:194,202 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:203,211
	  void
	  userinit(void)
	  {
	+ 	void *v;
	  	Proc *p;
	  	Segment *s;
	- 	KMap *k;
	  	Page *pg;
	  
	  	p = newproc();
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:226,239 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:235,252
	  
	  	/*
	  	 * User Stack
	+ 	 *
	+ 	 * N.B. cannot call newpage() with clear=1, because pc kmap
	+ 	 * requires up != nil.  use tmpmap instead.
	  	 */
	  	s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG);
	  	p->seg[SSEG] = s;
	- 	pg = newpage(1, 0, USTKTOP-BY2PG);
	+ 	pg = newpage(0, 0, USTKTOP-BY2PG);
	+ 	v = tmpmap(pg);
	+ 	memset(v, 0, BY2PG);
	  	segpage(s, pg);
	- 	k = kmap(pg);
	- 	bootargs(VA(k));
	- 	kunmap(k);
	+ 	bootargs(v);
	+ 	tmpunmap(v);
	  
	  	/*
	  	 * Text
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:241,252 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:254,266
	  	s = newseg(SG_TEXT, UTZERO, 1);
	  	s->flushme++;
	  	p->seg[TSEG] = s;
	- 	pg = newpage(1, 0, UTZERO);
	+ 	pg = newpage(0, 0, UTZERO);
	  	memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
	  	segpage(s, pg);
	- 	k = kmap(s->map[0]->pages[0]);
	- 	memmove((ulong*)VA(k), initcode, sizeof initcode);
	- 	kunmap(k);
	+ 	v = tmpmap(pg);
	+ 	memset(v, 0, BY2PG);
	+ 	memmove(v, initcode, sizeof initcode);
	+ 	tmpunmap(v);
	  
	  	ready(p);
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:263,269 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:277,283
	  }
	  
	  void
	- bootargs(ulong base)
	+ bootargs(void *base)
	  {
	   	int i, ac;
	  	uchar *av[32];
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:295,303 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:309,317
	  	sp -= (ac+1)*sizeof(sp);
	  	lsp = (uchar**)sp;
	  	for(i = 0; i < ac; i++)
	- 		*lsp++ = av[i] + ((USTKTOP - BY2PG) - base);
	+ 		*lsp++ = av[i] + ((USTKTOP - BY2PG) - (ulong)base);
	  	*lsp = 0;
	- 	sp += (USTKTOP - BY2PG) - base - sizeof(ulong);
	+ 	sp += (USTKTOP - BY2PG) - (ulong)base - sizeof(ulong);
	  }
	  
	  char*
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:344,350 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:358,364
	  confinit(void)
	  {
	  	char *p;
	- 	int userpcnt;
	+ 	int i, userpcnt;
	  	ulong kpages;
	  
	  	if(p = getconf("*kernelpercent"))
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:352,358 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:366,374
	  	else
	  		userpcnt = 0;
	  
	- 	conf.npage = conf.npage0 + conf.npage1;
	+ 	conf.npage = 0;
	+ 	for(i=0; i<nelem(conf.mem); i++)
	+ 		conf.npage += conf.mem[i].npage;
	  
	  	conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5;
	  	if(cpuserver)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:397,402 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:413,426
	  		if(conf.npage*BY2PG < 16*MB)
	  			imagmem->minarena = 4*1024*1024;
	  	}
	+ 
	+ 	/*
	+ 	 * can't go past the end of virtual memory
	+ 	 * (ulong)-KZERO is 2^32 - KZERO
	+ 	 */
	+ 	if(kpages > ((ulong)-KZERO)/BY2PG)
	+ 		kpages = ((ulong)-KZERO)/BY2PG;
	+ 
	  	conf.upages = conf.npage - kpages;
	  	conf.ialloc = (kpages/2)*BY2PG;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:493,499 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:517,523
	   *  math coprocessor emulation fault
	   */
	  static void
	- mathemu(Ureg*, void*)
	+ mathemu(Ureg *ureg, void*)
	  {
	  	if(up->fpstate & FPillegal){
	  		/* someone did floating point in a note handler */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/main.c:521,527 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/main.c:545,552
	  		up->fpstate = FPactive;
	  		break;
	  	case FPactive:
	- 		panic("math emu");
	+ 		panic("math emu pid %ld %s pc 0x%lux", 
	+ 			up->pid, up->text, ureg->pc);
	  		break;
	  	}
	  }
 [rsc] --rw-rw-r-- M 451989 glenda sys 5209 Nov  6 10:20 sys/src/9/pc/mem.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mem.h:11,16 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mem.h:11,17
	  #define	BY2V		8			/* bytes per double word */
	  #define	BY2PG		4096			/* bytes per page */
	  #define	WD2PG		(BY2PG/BY2WD)		/* words per page */
	+ #define	BY2XPG		(4096*1024)	/* bytes per big page */
	  #define	PGSHIFT		12			/* log(BY2PG) */
	  #define	ROUND(s, sz)	(((s)+((sz)-1))&~((sz)-1))
	  #define	PGROUND(s)	ROUND(s, BY2PG)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mem.h:27,66 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mem.h:28,75
	  #define	TK2SEC(t)	((t)/HZ)		/* ticks to seconds */
	  
	  /*
	-  * Fundamental addresses
	-  */
	- #define	IDTADDR		0x80000800		/* idt */
	- #define	REBOOTADDR	0x00001000		/* reboot code - physical address */
	- #define	APBOOTSTRAP	0x80001000		/* AP bootstrap code */
	- #define	CONFADDR	0x80001200		/* info passed from boot loader */
	- #define	CPU0PDB		0x80002000		/* bootstrap processor PDB */
	- #define	CPU0PTE		0x80003000		/* bootstrap processor PTE's for 0-4MB */
	- #define	CPU0GDT		0x80004000		/* bootstrap processor GDT */
	- #define	MACHADDR	0x80005000		/* as seen by current processor */
	- #define	CPU0MACH	0x80006000		/* Mach for bootstrap processor */
	- #define	MACHSIZE	BY2PG
	- /*
	-  * N.B.  ramscan knows that CPU0MACH+BY2PG is the end of reserved data
	-  * N.B.  _start0x00100020 knows that CPU0PDB is the first reserved page
	-  * and that there are 5 of them.
	-  */
	- 
	- /*
	   *  Address spaces
	-  *
	-  *  User is at 0-2GB
	-  *  Kernel is at 2GB-4GB
	   */
	+ #define	KZERO		0xF0000000		/* base of kernel address space */
	+ #define	KTZERO		(KZERO+0x100000)		/* first address in kernel text - 9load sits below */
	+ #define	VPT			(KZERO-VPTSIZE)
	+ #define	VPTSIZE		BY2XPG
	+ #define	NVPT		(VPTSIZE/BY2WD)
	+ #define	KMAP		(VPT-KMAPSIZE)
	+ #define	KMAPSIZE	BY2XPG
	+ #define	VMAP		(KMAP-VMAPSIZE)
	+ #define	VMAPSIZE	(0x10000000-VPTSIZE-KMAPSIZE)
	  #define	UZERO		0			/* base of user address space */
	  #define	UTZERO		(UZERO+BY2PG)		/* first address in user text */
	- #define	KZERO		0x80000000		/* base of kernel address space */
	- #define	KTZERO		0x80100000		/* first address in kernel text */
	- #define	USTKTOP		(KZERO-BY2PG)		/* byte just beyond user stack */
	+ #define	USTKTOP		(VMAP-BY2PG)		/* byte just beyond user stack */
	  #define	USTKSIZE	(16*1024*1024)		/* size of user stack */
	  #define	TSTKTOP		(USTKTOP-USTKSIZE)	/* end of new stack in sysexec */
	  #define	TSTKSIZ 	100
	  
	  /*
	+  * Fundamental addresses - bottom 64kB saved for return to real mode
	+  */
	+ #define	CONFADDR	(KZERO+0x1200)		/* info passed from boot loader */
	+ #define	TMPADDR		(KZERO+0x2000)		/* used for temporary mappings */
	+ #define	APBOOTSTRAP	(KZERO+0x3000)		/* AP bootstrap code */
	+ #define	RMUADDR		(KZERO+0x7C00)		/* real mode Ureg */
	+ #define	RMCODE		(KZERO+0x8000)		/* copy of first page of KTEXT */
	+ #define	RMBUF		(KZERO+0x9000)		/* buffer for user space - known to vga */
	+ #define	IDTADDR		(KZERO+0x10800)		/* idt */
	+ #define	REBOOTADDR	(KZERO+0x11000)		/* reboot code - physical address */
	+ #define	CPU0PDB		(KZERO+0x12000)		/* bootstrap processor PDB */
	+ #define	CPU0PTE		(KZERO+0x13000)		/* bootstrap processor PTE's for 0-4MB */
	+ #define	CPU0GDT		(KZERO+0x14000)		/* bootstrap processor GDT */
	+ #define	MACHADDR	(KZERO+0x15000)		/* as seen by current processor */
	+ #define	CPU0MACH	(KZERO+0x16000)		/* Mach for bootstrap processor */
	+ #define	MACHSIZE	BY2PG
	+ /*
	+  * N.B.  ramscan knows that CPU0MACH+BY2PG is the end of reserved data
	+  * N.B.  _startPADDR knows that CPU0PDB is the first reserved page
	+  * and that there are 5 of them.
	+  */
	+ 
	+ /*
	   *  known x86 segments (in GDT) and their selectors
	   */
	  #define	NULLSEG	0	/* null segment */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mem.h:72,77 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mem.h:81,87
	  #define	APMCSEG		6	/* APM code segment */
	  #define	APMCSEG16	7	/* APM 16-bit code segment */
	  #define	APMDSEG		8	/* APM data segment */
	+ #define	KESEG16		9	/* kernel executable 16-bit */
	  #define	NGDT		10	/* number of GDT entries required */
	  /* #define	APM40SEG	8	/* APM segment 0x40 */
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mem.h:141,143 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mem.h:151,154
	  #define	PTX(va)		((((ulong)(va))>>12) & 0x03FF)
	  
	  #define	getpgcolor(a)	0
	+ 
 [rsc] --rw-rw-r-- M 451989 glenda sys 18222 Nov  6 10:20 sys/src/9/pc/memory.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:8,13 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:8,14
	  #include "dat.h"
	  #include "fns.h"
	  #include "io.h"
	+ #include "ureg.h"
	  
	  #define MEMDEBUG	0
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:15,26 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:16,28
	  	MemUPA		= 0,		/* unbacked physical address */
	  	MemRAM		= 1,		/* physical memory */
	  	MemUMB		= 2,		/* upper memory block (<16MB) */
	- 	NMemType	= 3,
	+ 	MemReserved	= 3,
	+ 	NMemType	= 4,
	  
	  	KB		= 1024,
	  
	  	MemMinMB	= 4,		/* minimum physical memory (<=4MB) */
	- 	MemMaxMB	= 768,		/* maximum physical memory to check */
	+ 	MemMaxMB	= 3*1024+768,		/* maximum physical memory to check */
	  
	  	NMemBase	= 10,
	  };
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:27,33 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:29,35
	  
	  typedef struct Map Map;
	  struct Map {
	- 	int	size;
	+ 	ulong	size;
	  	ulong	addr;
	  };
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:40,45 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:42,50
	  	Lock;
	  };
	  
	+ /* 
	+  * Memory allocation tracking.
	+  */
	  static Map mapupa[16];
	  static RMap rmapupa = {
	  	"unallocated unbacked physical memory",
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:82,88 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:87,93
	  
	  	print("%s\n", rmap->name);	
	  	for(mp = rmap->map; mp->size; mp++)
	- 		print("\t%8.8luX %8.8uX %8.8luX\n", mp->addr, mp->size, mp->addr+mp->size);
	+ 		print("\t%8.8luX %8.8luX (%lud)\n", mp->addr, mp->addr+mp->size, mp->size);
	  }
	  
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:91,99 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:96,101
	  {
	  	ulong maxpa, maxpa1, maxpa2;
	  
	- 	if(MEMDEBUG == 0)
	- 		return;
	- 
	  	maxpa = (nvramread(0x18)<<8)|nvramread(0x17);
	  	maxpa1 = (nvramread(0x31)<<8)|nvramread(0x30);
	  	maxpa2 = (nvramread(0x16)<<8)|nvramread(0x15);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:209,214 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:211,231
	  	return 0;
	  }
	  
	+ /*
	+  * Allocate from the ram map directly to make page tables.
	+  * Called by mmuwalk during e820scan.
	+  */
	+ void*
	+ rampage(void)
	+ {
	+ 	ulong m;
	+ 	
	+ 	m = mapalloc(&rmapram, 0, BY2PG, BY2PG);
	+ 	if(m == 0)
	+ 		return nil;
	+ 	return KADDR(m);
	+ }
	+ 
	  static void
	  umbscan(void)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:269,287 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:286,297
	  }
	  
	  static void
	- ramscan(ulong maxmem)
	+ lowraminit(void)
	  {
	- 	ulong *k0, kzero, map, maxpa, pa, *pte, *table, *va, x, n;
	- 	int nvalid[NMemType];
	+ 	ulong n, pa, x;
	  	uchar *bda;
	  
	  	/*
	- 	 * The bootstrap code has has created a prototype page
	- 	 * table which maps the first MemMinMB of physical memory to KZERO.
	- 	 * The page directory is at m->pdb and the first page of
	- 	 * free memory is after the per-processor MMU information.
	- 	 */
	- 	/*
	  	 * Initialise the memory bank information for conventional memory
	  	 * (i.e. less than 640KB). The base is the first location after the
	  	 * bootstrap processor MMU information and the limit is obtained from
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:297,304 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:307,329
	  	pa = MemMinMB*MB;
	  	mapfree(&rmapram, x, pa-x);
	  	memset(KADDR(x), 0, pa-x);		/* keep us honest */
	+ }
	  
	+ static void
	+ ramscan(ulong maxmem)
	+ {
	+ 	ulong *k0, kzero, map, maxkpa, maxpa, pa, *pte, *table, *va, vbase, x;
	+ 	int nvalid[NMemType];
	+ 
	  	/*
	+ 	 * The bootstrap code has has created a prototype page
	+ 	 * table which maps the first MemMinMB of physical memory to KZERO.
	+ 	 * The page directory is at m->pdb and the first page of
	+ 	 * free memory is after the per-processor MMU information.
	+ 	 */
	+ 	pa = MemMinMB*MB;
	+ 
	+ 	/*
	  	 * Check if the extended memory size can be obtained from the CMOS.
	  	 * If it's 0 then it's either not known or >= 64MB. Always check
	  	 * at least 24MB in case there's a memory gap (up to 8MB) below 16MB;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:314,323 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:339,347
	  			maxpa = MB+x*KB;
	  		if(maxpa < 24*MB)
	  			maxpa = 24*MB;
	- 		maxmem = MemMaxMB*MB;
	- 	}
	- 	else
	+ 	}else
	  		maxpa = maxmem;
	+ 	maxkpa = (u32int)-KZERO;	/* 2^32 - KZERO */
	  
	  	/*
	  	 * March up memory from MemMinMB to maxpa 1MB at a time,
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:330,344 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:354,377
	  	map = 0;
	  	x = 0x12345678;
	  	memset(nvalid, 0, sizeof(nvalid));
	+ 	
	+ 	/*
	+ 	 * Can't map memory to KADDR(pa) when we're walking because
	+ 	 * can only use KADDR for relatively low addresses.  Instead,
	+ 	 * map each 4MB we scan to the virtual address range 4MB-8MB
	+ 	 * while we are scanning.
	+ 	 */
	+ 	vbase = 4*MB;
	  	while(pa < maxpa){
	  		/*
	  		 * Map the page. Use mapalloc(&rmapram, ...) to make
	  		 * the page table if necessary, it will be returned to the
	- 		 * pool later if it isn't needed.
	+ 		 * pool later if it isn't needed.  Map in a fixed range (the second 4M)
	+ 		 * because high physical addresses cannot be passed to KADDR.
	  		 */
	- 		va = KADDR(pa);
	+ 		va = (void*)(vbase + pa%(4*MB));
	  		table = &m->pdb[PDX(va)];
	- 		if(*table == 0){
	+ 		if(pa%(4*MB) == 0){
	  			if(map == 0 && (map = mapalloc(&rmapram, 0, BY2PG, BY2PG)) == 0)
	  				break;
	  			memset(KADDR(map), 0, BY2PG);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:350,359 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:383,391
	  
	  		*pte = pa|PTEWRITE|PTEUNCACHED|PTEVALID;
	  		mmuflushtlb(PADDR(m->pdb));
	- 
	  		/*
	  		 * Write a pattern to the page and write a different
	- 		 * pattern to a possible mirror at KZER0. If the data
	+ 		 * pattern to a possible mirror at KZERO. If the data
	  		 * reads back correctly the chunk is some type of RAM (possibly
	  		 * a linearly-mapped VGA framebuffer, for instance...) and
	  		 * can be cleared and added to the memory pool. If not, the
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:389,395 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:421,426
	  			*pte = 0;
	  			pa += MB;
	  		}
	- 
	  		/*
	  		 * Done with this 4MB chunk, review the options:
	  		 * 1) not physical memory and >=16MB - invalidate the PDB entry;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:399,406 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:430,446
	  		 * 4) mixed or no 4MB page extension - commit the already
	  		 *    initialised space for the page table.
	  		 */
	- 		if((pa % (4*MB)) == 0){
	- 			table = &m->pdb[PDX(va)];
	+ 		if(pa%(4*MB) == 0 && pa >= 32*MB && nvalid[MemUPA] == (4*MB)/BY2PG){
	+ 			/*
	+ 			 * If we encounter a 4MB chunk of missing memory
	+ 			 * at a sufficiently high offset, call it the end of
	+ 			 * memory.  Otherwise we run the risk of thinking
	+ 			 * that video memory is real RAM.
	+ 			 */
	+ 			break;
	+ 		}
	+ 		if(pa <= maxkpa && pa%(4*MB) == 0){
	+ 			table = &m->pdb[PDX(KADDR(pa - 4*MB))];
	  			if(nvalid[MemUPA] == (4*MB)/BY2PG)
	  				*table = 0;
	  			else if(nvalid[MemRAM] == (4*MB)/BY2PG && (m->cpuiddx & 0x08))
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:407,444 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:447,713
	  				*table = (pa - 4*MB)|PTESIZE|PTEWRITE|PTEVALID;
	  			else if(nvalid[MemUMB] == (4*MB)/BY2PG && (m->cpuiddx & 0x08))
	  				*table = (pa - 4*MB)|PTESIZE|PTEWRITE|PTEUNCACHED|PTEVALID;
	- 			else
	+ 			else{
	+ 				*table = map|PTEWRITE|PTEVALID;
	  				map = 0;
	+ 			}
	  		}
	- 
	  		mmuflushtlb(PADDR(m->pdb));
	  		x += 0x3141526;
	  	}
	- 
	  	/*
	  	 * If we didn't reach the end of the 4MB chunk, that part won't
	  	 * be mapped.  Commit the already initialised space for the page table.
	  	 */
	- 	if(pa % (4*MB))
	+ 	if(pa % (4*MB) && pa <= maxkpa){
	+ 		m->pdb[PDX(KADDR(pa))] = map|PTEWRITE|PTEVALID;
	  		map = 0;
	- 
	+ 	}
	  	if(map)
	  		mapfree(&rmapram, map, BY2PG);
	- 	if(pa < maxmem)
	- 		mapfree(&rmapupa, pa, maxmem-pa);
	- 	if(maxmem < 0xFFE00000)
	- 		mapfree(&rmapupa, maxmem, 0x00000000-maxmem);
	- 	if(MEMDEBUG)
	- 		print("maxmem %luX %luX\n", maxmem, 0x00000000-maxmem);
	+ 
	+ 	m->pdb[PDX(vbase)] = 0;
	+ 	mmuflushtlb(PADDR(m->pdb));
	+ 
	+ 	mapfree(&rmapupa, pa, (u32int)-pa);
	  	*k0 = kzero;
	  }
	  
	+ /*
	+  * BIOS Int 0x15 E820 memory map.
	+  */
	+ enum
	+ {
	+ 	SMAP = ('S'<<24)|('M'<<16)|('A'<<8)|'P',
	+ 	Ememory = 1,
	+ 	Ereserved = 2,
	+ 	Carry = 1,
	+ };
	+ 
	+ typedef struct Emap Emap;
	+ struct Emap
	+ {
	+ 	uvlong base;
	+ 	uvlong len;
	+ 	ulong type;
	+ };
	+ static Emap emap[16];
	+ int nemap;
	+ 
	+ static char *etypes[] =
	+ {
	+ 	"type=0",
	+ 	"memory",
	+ 	"reserved",
	+ 	"acpi reclaim",
	+ 	"acpi nvs",
	+ };
	+ 
	+ static int
	+ emapcmp(const void *va, const void *vb)
	+ {
	+ 	Emap *a, *b;
	+ 	
	+ 	a = (Emap*)va;
	+ 	b = (Emap*)vb;
	+ 	if(a->base < b->base)
	+ 		return -1;
	+ 	if(a->base > b->base)
	+ 		return 1;
	+ 	if(a->len < b->len)
	+ 		return -1;
	+ 	if(a->len > b->len)
	+ 		return 1;
	+ 	return a->type - b->type;
	+ }
	+ 
	+ static void
	+ map(ulong base, ulong len, int type)
	+ {
	+ 	ulong e, n;
	+ 	ulong *table, flags, maxkpa;
	+ 	
	+ 	/*
	+ 	 * Split any call crossing 4*MB to make below simpler.
	+ 	 */
	+ 	if(base < 4*MB && len > 4*MB-base){
	+ 		n = 4*MB - base;
	+ 		map(base, n, type);
	+ 		map(4*MB, len-n, type);
	+ 	}
	+ 	
	+ 	/*
	+ 	 * Let lowraminit and umbscan hash out the low 4MB.
	+ 	 */
	+ 	if(base < 4*MB)
	+ 		return;
	+ 
	+ 	/*
	+ 	 * Any non-memory below 16*MB is used as upper mem blocks.
	+ 	 */
	+ 	if(type == MemUPA && base < 16*MB && base+len > 16*MB){
	+ 		map(base, 16*MB-base, MemUMB);
	+ 		map(16*MB, len-(16*MB-base), MemUPA);
	+ 		return;
	+ 	}
	+ 	
	+ 	/*
	+ 	 * Memory below CPU0MACH is reserved for the kernel
	+ 	 * and already mapped.
	+ 	 */
	+ 	if(base < PADDR(CPU0MACH)+BY2PG){
	+ 		n = PADDR(CPU0MACH)+BY2PG - base;
	+ 		if(len <= n)
	+ 			return;
	+ 		map(PADDR(CPU0MACH), len-n, type);
	+ 		return;
	+ 	}
	+ 	
	+ 	/*
	+ 	 * Memory between KTZERO and end is the kernel itself
	+ 	 * and is already mapped.
	+ 	 */
	+ 	if(base < PADDR(KTZERO) && base+len > PADDR(KTZERO)){
	+ 		map(base, PADDR(KTZERO)-base, type);
	+ 		return;
	+ 	}
	+ 	if(PADDR(KTZERO) < base && base < PADDR(PGROUND((ulong)end))){
	+ 		n = PADDR(PGROUND((ulong)end));
	+ 		if(len <= n)
	+ 			return;
	+ 		map(PADDR(PGROUND((ulong)end)), len-n, type);
	+ 		return;
	+ 	}
	+ 	
	+ 	/*
	+ 	 * Now we have a simple case.
	+ 	 */
	+ 	// print("map %.8lux %.8lux %d\n", base, base+len, type);
	+ 	switch(type){
	+ 	case MemRAM:
	+ 		mapfree(&rmapram, base, len);
	+ 		flags = PTEWRITE;
	+ 		break;
	+ 	case MemUMB:
	+ 		mapfree(&rmapumb, base, len);
	+ 		flags = PTEWRITE|PTEUNCACHED;
	+ 		break;
	+ 	case MemUPA:
	+ 		mapfree(&rmapupa, base, len);
	+ 		/* don't need to map this but will anyway */
	+ 		flags = PTEWRITE|PTEUNCACHED;
	+ 		break;
	+ 	default:
	+ 	case MemReserved:
	+ 		/* don't put in any pools but still map it. */
	+ 		flags = PTEWRITE|PTEUNCACHED;
	+ 		break;
	+ 	}
	+ 	
	+ 	/*
	+ 	 * bottom 4MB is already mapped - just twiddle flags.
	+ 	 * (not currently used - see above)
	+ 	 */
	+ 	if(base < 4*MB){
	+ 		table = KADDR(PPN(m->pdb[PDX(base)]));
	+ 		e = base+len;
	+ 		base = PPN(base);
	+ 		for(; base<e; base+=BY2PG)
	+ 			table[PTX(base)] |= flags;
	+ 		return;
	+ 	}
	+ 	
	+ 	/*
	+ 	 * Only map from KZERO to 2^32.
	+ 	 */
	+ 	maxkpa = -KZERO;
	+ 	if(base >= maxkpa)
	+ 		return;
	+ 	if(len > maxkpa-base)
	+ 		len = maxkpa - base;
	+ 	pdbmap(m->pdb, base|flags, base+KZERO, len);
	+ }
	+ 
	+ static int
	+ e820scan(void)
	+ {
	+ 	int i;
	+ 	Ureg u;
	+ 	ulong cont, base, last, len;
	+ 	Emap *e;
	+ 
	+ 	if(getconf("*norealmode") || getconf("*noe820scan"))
	+ 		return -1;
	+ 
	+ 	cont = 0;
	+ 	for(i=0; i<nelem(emap); i++){
	+ 		memset(&u, 0, sizeof u);
	+ 		u.ax = 0xE820;
	+ 		u.bx = cont;
	+ 		u.cx = 20;
	+ 		u.dx = SMAP;
	+ 		u.es = (PADDR(RMBUF)>>4)&0xF000;
	+ 		u.di = PADDR(RMBUF)&0xFFFF;
	+ 		u.trap = 0x15;
	+ 		realmode(&u);
	+ 		cont = u.bx;
	+ 		if((u.flags&Carry) || u.ax != SMAP || u.cx != 20)
	+ 			break;
	+ 		e = &emap[nemap++];
	+ 		*e = *(Emap*)RMBUF;
	+ 		if(u.bx == 0)
	+ 			break;
	+ 	}
	+ 	if(nemap == 0)
	+ 		return -1;
	+ 	
	+ 	qsort(emap, nemap, sizeof emap[0], emapcmp);
	+ 	
	+ 	for(i=0; i<nemap; i++){
	+ 		e = &emap[i];
	+ 		print("E820: %.8llux %.8llux ", e->base, e->base+e->len);
	+ 		if(e->type < nelem(etypes))
	+ 			print("%s\n", etypes[e->type]);
	+ 		else
	+ 			print("type=%lud\n", e->type);
	+ 	}
	+ 
	+ 	last = 0;
	+ 	for(i=0; i<nemap; i++){	
	+ 		e = &emap[i];
	+ 		/*
	+ 		 * pull out the info but only about the low 32 bits...
	+ 		 */
	+ 		if(e->base >= (1LL<<32))
	+ 			break;
	+ 		base = e->base;
	+ 		if(base+e->len > (1LL<<32))
	+ 			len = -base;
	+ 		else
	+ 			len = e->len;
	+ 		/*
	+ 		 * If the map skips addresses, mark them available.
	+ 		 */
	+ 		if(last < e->base)
	+ 			map(last, e->base-last, MemUPA);
	+ 		last = base+len;
	+ 		if(e->type == Ememory)
	+ 			map(base, len, MemRAM);
	+ 		else
	+ 			map(base, len, MemReserved);
	+ 	}
	+ 	
	+ 	return 0;
	+ }
	+ 
	  void
	  meminit(void)
	  {
	- 	Map *mp, *xmp;
	+ 	int i;
	+ 	Map *mp;
	+ 	Confmem *cm;
	  	ulong pa, *pte;
	- 	ulong maxmem;
	+ 	ulong maxmem, lost;
	  	char *p;
	  
	  	if(p = getconf("*maxmem"))
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:463,493 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:732,764
	  	mmuflushtlb(PADDR(m->pdb));
	  
	  	umbscan();
	- 	ramscan(maxmem);
	+ 	lowraminit();
	+ 	if(e820scan() < 0)
	+ 		ramscan(maxmem);
	  
	  	/*
	- 	 * Set the conf entries describing two banks of allocatable memory.
	- 	 * Grab the first and largest entries in rmapram as left by ramscan().
	- 	 *
	- 	 * It would be nice to have more than 2 memory banks describable in conf.
	+ 	 * Set the conf entries describing banks of allocatable memory.
	  	 */
	- 	mp = rmapram.map;
	- 	conf.base0 = mp->addr;
	- 	conf.npage0 = mp->size/BY2PG;
	- 	mp++;
	- 	for(xmp = 0; mp->size; mp++){
	- 		if(xmp == 0 || mp->size > xmp->size)
	- 			xmp = mp;
	+ 	for(i=0; i<nelem(mapram) && i<nelem(conf.mem); i++){
	+ 		mp = &rmapram.map[i];
	+ 		cm = &conf.mem[i];
	+ 		cm->base = mp->addr;
	+ 		cm->npage = mp->size/BY2PG;
	  	}
	+ 	
	+ 	lost = 0;
	+ 	for(; i<nelem(mapram); i++)
	+ 		lost += rmapram.map[i].size;
	+ 	if(lost)
	+ 		print("meminit - lost %lud bytes\n", lost);
	  
	- 	if(xmp){		
	- 		conf.base1 = xmp->addr;
	- 		conf.npage1 = xmp->size/BY2PG;
	- 	}
	  	if(MEMDEBUG)
	  		memdebug();
	  }
	  
	+ /*
	+  * Allocate memory from the upper memory blocks.
	+  */
	  ulong
	  umbmalloc(ulong addr, int size, int align)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:536,576 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:807,828
	  	mapfree(&rmapumbrw, PADDR(addr), size);
	  }
	  
	+ /*
	+  * Give out otherwise-unused physical address space
	+  * for use in configuring devices.  Note that unlike upamalloc
	+  * before it, upaalloc does not map the physical address
	+  * into virtual memory.  Call vmap to do that.
	+  */
	  ulong
	- upamalloc(ulong pa, int size, int align)
	+ upaalloc(int size, int align)
	  {
	- 	ulong a, ae;
	+ 	ulong a;
	  
	- 	if(a = mapalloc(&xrmapupa, pa, size, align))
	- 		return a;
	- 
	- 	if((a = mapalloc(&rmapupa, pa, size, align)) == 0){
	- 		memdebug();
	- 		return 0;
	+ 	a = mapalloc(&rmapupa, 0, size, align);
	+ 	if(a == 0){
	+ 		print("out of physical address space allocating %d\n", size);
	+ 		mapprint(&rmapupa);
	  	}
	- 
	- 	/*
	- 	 * Upamalloc is a request to map a range of physical addresses.
	- 	 * Therefore, if pa is 0 mapalloc will choose the base address.
	- 	 * Note, however, mmukmap is always asked to give a 1-to-1 mapping
	- 	 * of va to pa.
	- 	ae = mmukmap(a, a, size);
	- 	 * ...but for the moment go back to the old scheme for VLB cards.
	- 	 */
	- 	ae = mmukmap(a, 0, size);
	- 
	- 	/*
	- 	 * Should check here that it was all delivered
	- 	 * and put it back and barf if not.
	- 	 */
	- 	USED(ae);
	- 
	- 	/*
	- 	 * Be very careful this returns a PHYSICAL address
	- 	 * mapped 1-to-1 with the virtual address.
	- 	 * If a < KZERO it's probably not a good idea to
	- 	 * try KADDR(a)...
	- 	 */
	  	return a;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/memory.c:577,582 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/memory.c:829,858
	  void
	  upafree(ulong pa, int size)
	  {
	- 	mapfree(&xrmapupa, pa, size);
	+ 	mapfree(&rmapupa, pa, size);
	+ }
	+ 
	+ void
	+ upareserve(ulong pa, int size)
	+ {
	+ 	ulong a;
	+ 	
	+ 	a = mapalloc(&rmapupa, pa, size, 0);
	+ 	if(a != pa){
	+ 		/*
	+ 		 * This can happen when we're using the E820
	+ 		 * map, which might have already reserved some
	+ 		 * of the regions claimed by the pci devices.
	+ 		 */
	+ 	//	print("upareserve: cannot reserve pa=%#.8lux size=%d\n", pa, size);
	+ 		if(a != 0)
	+ 			mapfree(&rmapupa, a, size);
	+ 	}
	+ }
	+ 
	+ void
	+ memorysummary(void)
	+ {
	+ 	memdebug();
	  }
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 19739 Nov  6 20:17 sys/src/9/pc/mmu.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mmu.c:1,3 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mmu.c:1,37
	+ /*
	+  * Memory mappings.  Life was easier when 2G of memory was enough.
	+  *
	+  * The kernel memory starts at KZERO, with the text loaded at KZERO+1M
	+  * (9load sits under 1M during the load).  The memory from KZERO to the
	+  * top of memory is mapped 1-1 with physical memory, starting at physical
	+  * address 0.  All kernel memory and data structures (i.e., the entries stored
	+  * into conf.mem) must sit in this physical range: if KZERO is at 0xF0000000,
	+  * then the kernel can only have 256MB of memory for itself.
	+  * 
	+  * The 256M below KZERO comprises three parts.  The lowest 4M is the
	+  * virtual page table, a virtual address representation of the current 
	+  * page table tree.  The second 4M is used for temporary per-process
	+  * mappings managed by kmap and kunmap.  The remaining 248M is used
	+  * for global (shared by all procs and all processors) device memory
	+  * mappings and managed by vmap and vunmap.  The total amount (256M)
	+  * could probably be reduced somewhat if desired.  The largest device
	+  * mapping is that of the video card, and even though modern video cards
	+  * have embarrassing amounts of memory, the video drivers only use one
	+  * frame buffer worth (at most 16M).  Each is described in more detail below.
	+  *
	+  * The VPT is a 4M frame constructed by inserting the pdb into itself.
	+  * This short-circuits one level of the page tables, with the result that 
	+  * the contents of second-level page tables can be accessed at VPT.  
	+  * We use the VPT to edit the page tables (see mmu) after inserting them
	+  * into the page directory.  It is a convenient mechanism for mapping what
	+  * might be otherwise-inaccessible pages.  The idea was borrowed from
	+  * the Exokernel.
	+  *
	+  * The VPT doesn't solve all our problems, because we still need to 
	+  * prepare page directories before we can install them.  For that, we
	+  * use tmpmap/tmpunmap, which map a single page at TMPADDR.
	+  */
	+ 
	  #include	"u.h"
	  #include	"../port/lib.h"
	  #include	"mem.h"
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mmu.c:5,12 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mmu.c:39,50
	  #include	"fns.h"
	  #include	"io.h"
	  
	+ /*
	+  * Simple segment descriptors with no translation.
	+  */
	  #define	DATASEGM(p) 	{ 0xFFFF, SEGG|SEGB|(0xF<<16)|SEGP|SEGPL(p)|SEGDATA|SEGW }
	  #define	EXECSEGM(p) 	{ 0xFFFF, SEGG|SEGD|(0xF<<16)|SEGP|SEGPL(p)|SEGEXEC|SEGR }
	+ #define	EXEC16SEGM(p) 	{ 0xFFFF, SEGG|(0xF<<16)|SEGP|SEGPL(p)|SEGEXEC|SEGR }
	  #define	TSSSEGM(b,p)	{ ((b)<<16)|sizeof(Tss),\
	  			  ((b)&0xFF000000)|(((b)>>16)&0xFF)|SEGTSS|SEGPL(p)|SEGP }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mmu.c:18,80 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mmu.c:56,76
	  [UDSEG]		DATASEGM(3),		/* user data/stack */
	  [UESEG]		EXECSEGM(3),		/* user code */
	  [TSSSEG]	TSSSEGM(0,0),		/* tss segment */
	+ [KESEG16]		EXEC16SEGM(0),	/* kernel code 16-bit */
	  };
	  
	- static void
	- taskswitch(ulong pdb, ulong stack)
	- {
	- 	Tss *tss;
	+ static int didmmuinit;
	+ static void taskswitch(ulong, ulong);
	+ static void memglobal(void);
	  
	- 	tss = m->tss;
	- 	tss->ss0 = KDSEL;
	- 	tss->esp0 = stack;
	- 	tss->ss1 = KDSEL;
	- 	tss->esp1 = stack;
	- 	tss->ss2 = KDSEL;
	- 	tss->esp2 = stack;
	- 	tss->cr3 = pdb;
	- 	putcr3(pdb);
	- }
	+ #define	vpt ((ulong*)VPT)
	+ #define	VPTX(va)		(((ulong)(va))>>12)
	+ #define	vpd (vpt+VPTX(VPT))
	  
	- /* 
	-  * On processors that support it, we set the PTEGLOBAL bit in
	-  * page table and page directory entries that map kernel memory.
	-  * Doing this tells the processor not to bother flushing them
	-  * from the TLB when doing the TLB flush associated with a 
	-  * context switch (write to CR3).  Since kernel memory mappings
	-  * are never removed, this is safe.  (If we ever remove kernel memory
	-  * mappings, we can do a full flush by turning off the PGE bit in CR4,
	-  * writing to CR3, and then turning the PGE bit back on.) 
	-  *
	-  * See also mmukmap below.
	-  * 
	-  * Processor support for the PTEGLOBAL bit is enabled in devarch.c.
	-  */
	- static void
	- memglobal(void)
	+ void
	+ mmuinit0(void)
	  {
	- 	int i, j;
	- 	ulong *pde, *pte;
	- 
	- 	/* only need to do this once, on bootstrap processor */
	- 	if(m->machno != 0)
	- 		return;
	- 
	- 	if(!m->havepge)
	- 		return;
	- 
	- 	pde = m->pdb;
	- 	for(i=512; i<1024; i++){	/* 512: start at entry for virtual 0x80000000 */
	- 		if(pde[i] & PTEVALID){
	- 			pde[i] |= PTEGLOBAL;
	- 			if(!(pde[i] & PTESIZE)){
	- 				pte = KADDR(pde[i]&~(BY2PG-1));
	- 				for(j=0; j<1024; j++)
	- 					if(pte[j] & PTEVALID)
	- 						pte[j] |= PTEGLOBAL;
	- 			}
	- 		}
	- 	}			
	+ 	memmove(m->gdt, gdt, sizeof gdt);
	  }
	  
	  void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mmu.c:83,90 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mmu.c:79,92
	  	ulong x, *p;
	  	ushort ptr[3];
	  
	- 	memglobal();
	+ 	didmmuinit = 1;
	  
	+ 	if(0) print("vpt=%#.8ux vpd=%#.8lux kmap=%#.8ux\n",
	+ 		VPT, (ulong)vpd, KMAP);
	+ 
	+ 	memglobal();
	+ 	m->pdb[PDX(VPT)] = PADDR(m->pdb)|PTEWRITE|PTEVALID;
	+ 	
	  	m->tss = malloc(sizeof(Tss));
	  	memset(m->tss, 0, sizeof(Tss));
	  	m->tss->iomap = 0xDFFF<<16;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mmu.c:98,104 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mmu.c:100,105
	  	 * than Intels in this regard).  Under VMware it pays off
	  	 * a factor of about 10 to 100.
	  	 */
	- 
	  	memmove(m->gdt, gdt, sizeof gdt);
	  	x = (ulong)m->tss;
	  	m->gdt[TSSSEG].d0 = (x<<16)|sizeof(Tss);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mmu.c:128,133 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mmu.c:129,180
	  	ltr(TSSSEL);
	  }
	  
	+ /* 
	+  * On processors that support it, we set the PTEGLOBAL bit in
	+  * page table and page directory entries that map kernel memory.
	+  * Doing this tells the processor not to bother flushing them
	+  * from the TLB when doing the TLB flush associated with a 
	+  * context switch (write to CR3).  Since kernel memory mappings
	+  * are never removed, this is safe.  (If we ever remove kernel memory
	+  * mappings, we can do a full flush by turning off the PGE bit in CR4,
	+  * writing to CR3, and then turning the PGE bit back on.) 
	+  *
	+  * See also mmukmap below.
	+  * 
	+  * Processor support for the PTEGLOBAL bit is enabled in devarch.c.
	+  */
	+ static void
	+ memglobal(void)
	+ {
	+ 	int i, j;
	+ 	ulong *pde, *pte;
	+ 
	+ 	/* only need to do this once, on bootstrap processor */
	+ 	if(m->machno != 0)
	+ 		return;
	+ 
	+ 	if(!m->havepge)
	+ 		return;
	+ 
	+ 	pde = m->pdb;
	+ 	for(i=PDX(KZERO); i<1024; i++){
	+ 		if(pde[i] & PTEVALID){
	+ 			pde[i] |= PTEGLOBAL;
	+ 			if(!(pde[i] & PTESIZE)){
	+ 				pte = KADDR(pde[i]&~(BY2PG-1));
	+ 				for(j=0; j<1024; j++)
	+ 					if(pte[j] & PTEVALID)
	+ 						pte[j] |= PTEGLOBAL;
	+ 			}
	+ 		}
	+ 	}			
	+ }
	+ 
	+ /*
	+  * Flush all the user-space and device-mapping mmu info
	+  * for this process, because something has been deleted.
	+  * It will be paged back in on demand.
	+  */
	  void
	  flushmmu(void)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mmu.c:139,163 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mmu.c:186,293
	  	splx(s);
	  }
	  
	+ /*
	+  * Flush a single page mapping from the tlb.
	+  */
	+ void
	+ flushpg(ulong va)
	+ {
	+ 	if(X86FAMILY(m->cpuidax) >= 4)
	+ 		invlpg(va);
	+ 	else
	+ 		putcr3(m->tss->cr3);
	+ }
	+ 	
	+ /*
	+  * Allocate a new page for a page directory. 
	+  * We keep a small cache of pre-initialized
	+  * page directories in each mach.
	+  */
	+ static Page*
	+ mmupdballoc(void)
	+ {
	+ 	int s;
	+ 	Page *page;
	+ 	ulong *pdb;
	+ 
	+ 	s = splhi();
	+ 	if(m->pdbpool == 0){
	+ 		spllo();
	+ 		page = newpage(0, 0, 0);
	+ 		page->va = (ulong)vpd;
	+ 		splhi();
	+ 		pdb = tmpmap(page);
	+ 		memmove(pdb, m->pdb, BY2PG);
	+ 		pdb[PDX(VPT)] = page->pa|PTEWRITE|PTEVALID;	/* set up VPT */
	+ 		tmpunmap(pdb);
	+ 	}else{
	+ 		page = m->pdbpool;
	+ 		m->pdbpool = page->next;
	+ 		m->pdbcnt--;
	+ 	}
	+ 	splx(s);
	+ 	return page;
	+ }
	+ 
	  static void
	+ mmupdbfree(Proc *proc, Page *p)
	+ {
	+ 	if(islo())
	+ 		panic("mmupdbfree: islo");
	+ 	if(m->pdbcnt >= 10){
	+ 		p->next = proc->mmufree;
	+ 		proc->mmufree = p;
	+ 	}else{
	+ 		p->next = m->pdbpool;
	+ 		m->pdbpool = p;
	+ 	}
	+ }
	+ 
	+ /*
	+  * A user-space memory segment has been deleted, or the
	+  * process is exiting.  Clear all the pde entries for user-space
	+  * memory mappings and device mappings.  Any entries that
	+  * are needed will be paged back in as necessary.
	+  */
	+ static void
	  mmuptefree(Proc* proc)
	  {
	+ 	int s;
	  	ulong *pdb;
	  	Page **last, *page;
	  
	- 	if(proc->mmupdb && proc->mmuused){
	- 		pdb = (ulong*)proc->mmupdb->va;
	- 		last = &proc->mmuused;
	- 		for(page = *last; page; page = page->next){
	- 			pdb[page->daddr] = 0;
	- 			last = &page->next;
	- 		}
	- 		*last = proc->mmufree;
	- 		proc->mmufree = proc->mmuused;
	- 		proc->mmuused = 0;
	+ 	if(proc->mmupdb == nil || proc->mmuused == nil)
	+ 		return;
	+ 	s = splhi();
	+ 	pdb = tmpmap(proc->mmupdb);
	+ 	last = &proc->mmuused;
	+ 	for(page = *last; page; page = page->next){
	+ 		pdb[page->daddr] = 0;
	+ 		last = &page->next;
	  	}
	+ 	tmpunmap(pdb);
	+ 	splx(s);
	+ 	*last = proc->mmufree;
	+ 	proc->mmufree = proc->mmuused;
	+ 	proc->mmuused = 0;
	  }
	  
	+ static void
	+ taskswitch(ulong pdb, ulong stack)
	+ {
	+ 	Tss *tss;
	+ 
	+ 	tss = m->tss;
	+ 	tss->ss0 = KDSEL;
	+ 	tss->esp0 = stack;
	+ 	tss->ss1 = KDSEL;
	+ 	tss->esp1 = stack;
	+ 	tss->ss2 = KDSEL;
	+ 	tss->esp2 = stack;
	+ 	tss->cr3 = pdb;
	+ 	putcr3(pdb);
	+ }
	+ 
	  void
	  mmuswitch(Proc* proc)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mmu.c:169,215 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mmu.c:299,335
	  	}
	  
	  	if(proc->mmupdb){
	- 		pdb = (ulong*)proc->mmupdb->va;
	+ 		pdb = tmpmap(proc->mmupdb);
	  		pdb[PDX(MACHADDR)] = m->pdb[PDX(MACHADDR)];
	+ 		tmpunmap(pdb);
	  		taskswitch(proc->mmupdb->pa, (ulong)(proc->kstack+KSTACK));
	- 	}
	- 	else
	+ 	}else
	  		taskswitch(PADDR(m->pdb), (ulong)(proc->kstack+KSTACK));
	  }
	  
	+ /*
	+  * Release any pages allocated for a page directory base or page-tables
	+  * for this process:
	+  *   switch to the prototype pdb for this processor (m->pdb);
	+  *   call mmuptefree() to place all pages used for page-tables (proc->mmuused)
	+  *   onto the process' free list (proc->mmufree). This has the side-effect of
	+  *   cleaning any user entries in the pdb (proc->mmupdb);
	+  *   if there's a pdb put it in the cache of pre-initialised pdb's
	+  *   for this processor (m->pdbpool) or on the process' free list;
	+  *   finally, place any pages freed back into the free pool (palloc).
	+  * This routine is only called from sched() with palloc locked.
	+  */
	  void
	  mmurelease(Proc* proc)
	  {
	  	Page *page, *next;
	  
	- 	/*
	- 	 * Release any pages allocated for a page directory base or page-tables
	- 	 * for this process:
	- 	 *   switch to the prototype pdb for this processor (m->pdb);
	- 	 *   call mmuptefree() to place all pages used for page-tables (proc->mmuused)
	- 	 *   onto the process' free list (proc->mmufree). This has the side-effect of
	- 	 *   cleaning any user entries in the pdb (proc->mmupdb);
	- 	 *   if there's a pdb put it in the cache of pre-initialised pdb's
	- 	 *   for this processor (m->pdbpool) or on the process' free list;
	- 	 *   finally, place any pages freed back into the free pool (palloc).
	- 	 * This routine is only called from sched() with palloc locked.
	- 	 */
	  	taskswitch(PADDR(m->pdb), (ulong)m + BY2PG);
	- 	mmuptefree(proc);
	- 
	  	if(proc->mmupdb){
	- 		if(m->pdbcnt > 10){
	- 			proc->mmupdb->next = proc->mmufree;
	- 			proc->mmufree = proc->mmupdb;
	- 		}
	- 		else{
	- 			proc->mmupdb->next = m->pdbpool;
	- 			m->pdbpool = proc->mmupdb;
	- 			m->pdbcnt++;
	- 		}
	+ 		mmuptefree(proc);
	+ 		mmupdbfree(proc, proc->mmupdb);
	  		proc->mmupdb = 0;
	  	}
	- 
	  	for(page = proc->mmufree; page; page = next){
	  		next = page->next;
	  		if(--page->ref)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mmu.c:221,323 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mmu.c:341,430
	  	proc->mmufree = 0;
	  }
	  
	- static Page*
	- mmupdballoc(void)
	+ /*
	+  * Allocate and install pdb for the current process.
	+  */
	+ static void
	+ upallocpdb(void)
	  {
	  	int s;
	+ 	ulong *pdb;
	  	Page *page;
	- 
	+ 	
	+ 	page = mmupdballoc();
	  	s = splhi();
	- 	if(m->pdbpool == 0){
	- 		spllo();
	- 		page = newpage(0, 0, 0);
	- 		page->va = VA(kmap(page));
	- 		memmove((void*)page->va, m->pdb, BY2PG);
	- 	}
	- 	else{
	- 		page = m->pdbpool;
	- 		m->pdbpool = page->next;
	- 		m->pdbcnt--;
	- 	}
	+ 	pdb = tmpmap(page);
	+ 	pdb[PDX(MACHADDR)] = m->pdb[PDX(MACHADDR)];
	+ 	tmpunmap(pdb);
	+ 	up->mmupdb = page;
	+ 	mmuflushtlb(up->mmupdb->pa);
	  	splx(s);
	- 	return page;
	  }
	- 
	- void
	- checkmmu(ulong va, ulong pa)
	- {
	- 	ulong *pdb, *pte;
	- 	int pdbx;
	  	
	- 	if(up->mmupdb == 0)
	- 		return;
	- 
	- 	pdb = (ulong*)up->mmupdb->va;
	- 	pdbx = PDX(va);
	- 	if(PPN(pdb[pdbx]) == 0){
	- 		/* okay to be empty - will fault and get filled */
	- 		return;
	- 	}
	- 	
	- 	pte = KADDR(PPN(pdb[pdbx]));
	- 	if(pte[PTX(va)] == 0)
	- 		return;
	- 	if((pte[PTX(va)]&~4095) != pa)
	- 		print("%ld %s: va=0x%08lux pa=0x%08lux pte=0x%08lux\n",
	- 			up->pid, up->text,
	- 			va, pa, pte[PTX(va)]);
	- }
	- 
	+ /*
	+  * Update the mmu in response to a user fault.  pa may have PTEWRITE set.
	+  */
	  void
	  putmmu(ulong va, ulong pa, Page*)
	  {
	- 	int pdbx;
	+ 	int old;
	  	Page *page;
	- 	ulong *pdb, *pte;
	- 	int s;
	  
	- 	if(up->mmupdb == 0)
	- 		up->mmupdb = mmupdballoc();
	- 	pdb = (ulong*)up->mmupdb->va;
	- 	pdbx = PDX(va);
	+ 	if(up->mmupdb == nil)
	+ 		upallocpdb();
	  
	- 	if(PPN(pdb[pdbx]) == 0){
	- 		if(up->mmufree == 0){
	- 			page = newpage(1, 0, 0);
	- 			page->va = VA(kmap(page));
	- 		}
	- 		else {
	+ 	if(!(vpd[PDX(va)]&PTEVALID)){
	+ 		if(up->mmufree == 0)
	+ 			page = newpage(0, 0, 0);
	+ 		else{
	  			page = up->mmufree;
	  			up->mmufree = page->next;
	- 			memset((void*)page->va, 0, BY2PG);
	  		}
	- 		pdb[pdbx] = PPN(page->pa)|PTEUSER|PTEWRITE|PTEVALID;
	- 		page->daddr = pdbx;
	+ 		vpd[PDX(va)] = PPN(page->pa)|PTEUSER|PTEWRITE|PTEVALID;
	+ 		/* page is now mapped into the VPT - clear it */
	+ 		memset((void*)(VPT+PDX(va)*BY2PG), 0, BY2PG);
	+ 		page->daddr = PDX(va);
	  		page->next = up->mmuused;
	  		up->mmuused = page;
	  	}
	+ 	old = vpt[VPTX(va)];
	+ 	vpt[VPTX(va)] = pa|PTEUSER|PTEVALID;
	+ 	if(old&PTEVALID)
	+ 		flushpg(va);
	+ }
	  
	- 	pte = KADDR(PPN(pdb[pdbx]));
	- 	pte[PTX(va)] = pa|PTEUSER;
	- 
	- 	s = splhi();
	- 	pdb[PDX(MACHADDR)] = m->pdb[PDX(MACHADDR)];
	- 	mmuflushtlb(up->mmupdb->pa);
	- 	splx(s);
	+ /*
	+  * Double-check the user MMU.
	+  * Error checking only.
	+  */
	+ void
	+ checkmmu(ulong va, ulong pa)
	+ {
	+ 	if(up->mmupdb == 0)
	+ 		return;
	+ 	if(!(vpd[PDX(va)]&PTEVALID) || !(vpt[VPTX(va)]&PTEVALID))
	+ 		return;
	+ 	if(PPN(vpt[VPTX(va)]) != pa)
	+ 		print("%ld %s: va=0x%08lux pa=0x%08lux pte=0x%08lux\n",
	+ 			up->pid, up->text,
	+ 			va, pa, vpt[VPTX(va)]);
	  }
	  
	+ /*
	+  * Walk the page-table pointed to by pdb and return a pointer
	+  * to the entry for virtual address va at the requested level.
	+  * If the entry is invalid and create isn't requested then bail
	+  * out early. Otherwise, for the 2nd level walk, allocate a new
	+  * page-table page and register it in the 1st level.  This is used
	+  * only to edit kernel mappings, which use pages from kernel memory,
	+  * so it's okay to use KADDR to look at the tables.
	+  */
	  ulong*
	  mmuwalk(ulong* pdb, ulong va, int level, int create)
	  {
	- 	ulong pa, *table;
	+ 	ulong *table;
	+ 	void *map;
	  
	- 	/*
	- 	 * Walk the page-table pointed to by pdb and return a pointer
	- 	 * to the entry for virtual address va at the requested level.
	- 	 * If the entry is invalid and create isn't requested then bail
	- 	 * out early. Otherwise, for the 2nd level walk, allocate a new
	- 	 * page-table page and register it in the 1st level.
	- 	 */
	  	table = &pdb[PDX(va)];
	  	if(!(*table & PTEVALID) && create == 0)
	  		return 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mmu.c:334,496 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mmu.c:441,870
	  		if(*table & PTESIZE)
	  			panic("mmuwalk2: va %luX entry %luX\n", va, *table);
	  		if(!(*table & PTEVALID)){
	- 			pa = PADDR(xspanalloc(BY2PG, BY2PG, 0));
	- 			*table = pa|PTEWRITE|PTEVALID;
	+ 			/*
	+ 			 * Have to call low-level allocator from
	+ 			 * memory.c if we haven't set up the xalloc
	+ 			 * tables yet.
	+ 			 */
	+ 			if(didmmuinit)
	+ 				map = xspanalloc(BY2PG, BY2PG, 0);
	+ 			else
	+ 				map = rampage();
	+ 			if(map == nil)
	+ 				panic("mmuwalk xspanalloc failed");
	+ 			*table = PADDR(map)|PTEWRITE|PTEVALID;
	  		}
	  		table = KADDR(PPN(*table));
	- 
	  		return &table[PTX(va)];
	  	}
	  }
	  
	- static Lock mmukmaplock;
	+ /*
	+  * Device mappings are shared by all procs and processors and
	+  * live in the virtual range VMAP to VMAP+VMAPSIZE.  The master
	+  * copy of the mappings is stored in mach0->pdb, and they are
	+  * paged in from there as necessary by vmapsync during faults.
	+  */
	  
	- int
	- mmukmapsync(ulong va)
	- {
	- 	Mach *mach0;
	- 	ulong entry, *pte;
	+ static Lock vmaplock;
	  
	- 	mach0 = MACHP(0);
	+ static int findhole(ulong *a, int n, int count);
	+ static ulong vmapalloc(ulong size);
	+ static void pdbunmap(ulong*, ulong, int);
	  
	- 	ilock(&mmukmaplock);
	+ /*
	+  * Add a device mapping to the vmap range.
	+  */
	+ void*
	+ vmap(ulong pa, int size)
	+ {
	+ 	int osize;
	+ 	ulong o, va;
	+ 	
	+ 	/*
	+ 	 * might be asking for less than a page.
	+ 	 */
	+ 	osize = size;
	+ 	o = pa & (BY2PG-1);
	+ 	pa -= o;
	+ 	size += o;
	  
	- 	if((pte = mmuwalk(mach0->pdb, va, 1, 0)) == nil){
	- 		iunlock(&mmukmaplock);
	- 		return 0;
	+ 	size = ROUND(size, BY2PG);
	+ 	if(pa == 0){
	+ 		print("vmap pa=0 pc=%#.8lux\n", getcallerpc(&pa));
	+ 		return nil;
	  	}
	- 	if(!(*pte & PTESIZE) && mmuwalk(mach0->pdb, va, 2, 0) == nil){
	- 		iunlock(&mmukmaplock);
	+ 	ilock(&vmaplock);
	+ 	if((va = vmapalloc(size)) == 0 
	+ 	|| pdbmap(MACHP(0)->pdb, pa|PTEUNCACHED|PTEWRITE, va, size) < 0){
	+ 		iunlock(&vmaplock);
	  		return 0;
	  	}
	- 	entry = *pte;
	+ 	iunlock(&vmaplock);
	+ 	/* avoid trap on local processor
	+ 	for(i=0; i<size; i+=4*MB)
	+ 		vmapsync(va+i);
	+ 	*/
	+ 	USED(osize);
	+ //	print("  vmap %#.8lux %d => %#.8lux\n", pa+o, osize, va+o);
	+ 	return (void*)(va + o);
	+ }
	  
	- 	if(!(m->pdb[PDX(va)] & PTEVALID))
	- 		m->pdb[PDX(va)] = entry;
	+ static int
	+ findhole(ulong *a, int n, int count)
	+ {
	+ 	int have, i;
	+ 	
	+ 	have = 0;
	+ 	for(i=0; i<n; i++){
	+ 		if(a[i] == 0)
	+ 			have++;
	+ 		else
	+ 			have = 0;
	+ 		if(have >= count)
	+ 			return i+1 - have;
	+ 	}
	+ 	return -1;
	+ }
	  
	- 	if(up && up->mmupdb){
	- 		((ulong*)up->mmupdb->va)[PDX(va)] = entry;
	- 		mmuflushtlb(up->mmupdb->pa);
	+ /*
	+  * Look for free space in the vmap.
	+  */
	+ static ulong
	+ vmapalloc(ulong size)
	+ {
	+ 	int i, n, o;
	+ 	ulong *vpdb;
	+ 	int vpdbsize;
	+ 	
	+ 	vpdb = &MACHP(0)->pdb[PDX(VMAP)];
	+ 	vpdbsize = VMAPSIZE/(4*MB);
	+ 
	+ 	if(size >= 4*MB){
	+ 		n = (size+4*MB-1) / (4*MB);
	+ 		if((o = findhole(vpdb, vpdbsize, n)) != -1)
	+ 			return VMAP + o*4*MB;
	+ 		return VMAP + o;
	  	}
	- 	else
	- 		mmuflushtlb(PADDR(m->pdb));
	+ 	n = (size+BY2PG-1) / BY2PG;
	+ 	for(i=0; i<vpdbsize; i++)
	+ 		if((vpdb[i]&PTEVALID) && !(vpdb[i]&PTESIZE))
	+ 			if((o = findhole(KADDR(PPN(vpdb[i])), WD2PG, n)) != -1)
	+ 				return VMAP + i*4*MB + o*BY2PG;
	+ 	if((o = findhole(vpdb, vpdbsize, 1)) != -1)
	+ 		return VMAP + o*4*MB;
	+ 		
	+ 	/*
	+ 	 * could span page directory entries, but not worth the trouble.
	+ 	 * not going to be very much contention.
	+ 	 */
	+ 	return 0;
	+ }
	  
	- 	iunlock(&mmukmaplock);
	+ /*
	+  * Remove a device mapping from the vmap range.
	+  * Since pdbunmap does not remove page tables, just entries,
	+  * the call need not be interlocked with vmap.
	+  */
	+ void
	+ vunmap(void *v, int size)
	+ {
	+ 	int i;
	+ 	ulong va, o;
	+ 	Mach *nm;
	+ 	Proc *p;
	+ 	
	+ 	/*
	+ 	 * might not be aligned
	+ 	 */
	+ 	va = (ulong)v;
	+ 	o = va&(BY2PG-1);
	+ 	va -= o;
	+ 	size += o;
	+ 	size = ROUND(size, BY2PG);
	+ 	
	+ 	if(size < 0 || va < VMAP || va+size > VMAP+VMAPSIZE)
	+ 		panic("vunmap va=%#.8lux size=%#x pc=%#.8lux\n",
	+ 			va, size, getcallerpc(&va));
	  
	- 	return 1;
	+ 	pdbunmap(MACHP(0)->pdb, va, size);
	+ 	
	+ 	/*
	+ 	 * Flush mapping from all the tlbs and copied pdbs.
	+ 	 * This can be (and is) slow, since it is called only rarely.
	+ 	 */
	+ 	for(i=0; i<conf.nproc; i++){
	+ 		p = proctab(i);
	+ 		if(p->state == Dead)
	+ 			continue;
	+ 		if(p != up)
	+ 			p->newtlb = 1;
	+ 	}
	+ 	for(i=0; i<conf.nmach; i++){
	+ 		nm = MACHP(i);
	+ 		if(nm != m)
	+ 			nm->flushmmu = 1;
	+ 	}
	+ 	flushmmu();
	+ 	for(i=0; i<conf.nmach; i++){
	+ 		nm = MACHP(i);
	+ 		if(nm != m)
	+ 			while((active.machs&(1<<nm->machno)) && nm->flushmmu)
	+ 				;
	+ 	}
	  }
	  
	- ulong
	- mmukmap(ulong pa, ulong va, int size)
	+ /*
	+  * Add kernel mappings for pa -> va for a section of size bytes.
	+  */
	+ int
	+ pdbmap(ulong *pdb, ulong pa, ulong va, int size)
	  {
	- 	Mach *mach0;
	- 	ulong ova, pae, *table, pgsz, *pte, x;
	- 	int pse, sync;
	+ 	int pse;
	+ 	ulong pae, pgsz, *pte, *table;
	+ 	ulong flag;
	+ 	
	+ 	flag = pa&0xFFF;
	+ 	pa &= ~0xFFF;
	  
	- 	mach0 = MACHP(0);
	- 	if((mach0->cpuiddx & 0x08) && (getcr4() & 0x10))
	+ 	if((MACHP(0)->cpuiddx & 0x08) && (getcr4() & 0x10))
	  		pse = 1;
	  	else
	  		pse = 0;
	- 	sync = 0;
	  
	- 	pa = PPN(pa);
	- 	if(va == 0)
	- 		va = (ulong)KADDR(pa);
	- 	else
	- 		va = PPN(va);
	- 	ova = va;
	- 
	  	pae = pa + size;
	- 	ilock(&mmukmaplock);
	  	while(pa < pae){
	- 		table = &mach0->pdb[PDX(va)];
	- 		/*
	- 		 * Possibly already mapped.
	- 		 */
	- 		if(*table & PTEVALID){
	- 			if(*table & PTESIZE){
	- 				/*
	- 				 * Big page. Does it fit within?
	- 				 * If it does, adjust pgsz so the correct end can be
	- 				 * returned and get out.
	- 				 * If not, adjust pgsz up to the next 4MB boundary
	- 				 * and continue.
	- 				 */
	- 				x = PPN(*table);
	- 				if(x != pa)
	- 					panic("mmukmap1: pa %luX  entry %luX\n",
	- 						pa, *table);
	- 				x += 4*MB;
	- 				if(pae <= x){
	- 					pa = pae;
	- 					break;
	- 				}
	- 				pgsz = x - pa;
	- 				pa += pgsz;
	- 				va += pgsz;
	+ 		table = &pdb[PDX(va)];
	+ 		if((*table&PTEVALID) && (*table&PTESIZE))
	+ 			panic("vmap: va=%#.8lux pa=%#.8lux pde=%#.8lux",
	+ 				va, pa, *table);
	  
	- 				continue;
	- 			}
	- 			else{
	- 				/*
	- 				 * Little page. Walk to the entry.
	- 				 * If the entry is valid, set pgsz and continue.
	- 				 * If not, make it so, set pgsz, sync and continue.
	- 				 */
	- 				pte = mmuwalk(mach0->pdb, va, 2, 0);
	- 				if(pte && *pte & PTEVALID){
	- 					x = PPN(*pte);
	- 					if(x != pa)
	- 						panic("mmukmap2: pa %luX entry %luX\n",
	- 							pa, *pte);
	- 					pgsz = BY2PG;
	- 					pa += pgsz;
	- 					va += pgsz;
	- 					sync++;
	- 
	- 					continue;
	- 				}
	- 			}
	- 		}
	- 
	  		/*
	- 		 * Not mapped. Check if it can be mapped using a big page -
	- 		 * starts on a 4MB boundary, size >= 4MB and processor can do it.
	- 		 * If not a big page, walk the walk, talk the talk.
	- 		 * Sync is set.
	- 		 *
	- 		 * If we're creating a kernel mapping, we know that it will never
	- 		 * expire and thus we can set the PTEGLOBAL bit to make the entry
	- 	 	 * persist in the TLB across flushes.  If we do add support later for
	- 		 * unmapping kernel addresses, see devarch.c for instructions on
	- 		 * how to do a full TLB flush.
	+ 		 * Check if it can be mapped using a 4MB page:
	+ 		 * va, pa aligned and size >= 4MB and processor can do it.
	  		 */
	- 		if(pse && (pa % (4*MB)) == 0 && (pae >= pa+4*MB)){
	- 			*table = pa|PTESIZE|PTEWRITE|PTEUNCACHED|PTEVALID;
	- 			if((va&KZERO) && m->havepge)
	- 				*table |= PTEGLOBAL;
	+ 		if(pse && pa%(4*MB) == 0 && va%(4*MB) == 0 && (pae >= pa+4*MB)){
	+ 			*table = pa|PTESIZE|flag|PTEVALID;
	  			pgsz = 4*MB;
	- 		}
	- 		else{
	- 			pte = mmuwalk(mach0->pdb, va, 2, 1);
	- 			*pte = pa|PTEWRITE|PTEUNCACHED|PTEVALID;
	- 			if((va&KZERO) && m->havepge)
	- 				*pte |= PTEGLOBAL;
	+ 		}else{
	+ 			pte = mmuwalk(pdb, va, 2, 1);
	+ 			if(*pte&PTEVALID)
	+ 				panic("vmap: va=%#.8lux pa=%#.8lux pte=%#.8lux",
	+ 					va, pa, *pte);
	+ 			*pte = pa|flag|PTEVALID;
	  			pgsz = BY2PG;
	  		}
	  		pa += pgsz;
	  		va += pgsz;
	- 		sync++;
	  	}
	- 	iunlock(&mmukmaplock);
	+ 	return 0;
	+ }
	  
	+ /*
	+  * Remove mappings.  Must already exist, for sanity.
	+  * Only used for kernel mappings, so okay to use KADDR.
	+  */
	+ static void
	+ pdbunmap(ulong *pdb, ulong va, int size)
	+ {
	+ 	ulong vae;
	+ 	ulong *table;
	+ 	
	+ 	vae = va+size;
	+ 	while(va < vae){
	+ 		table = &pdb[PDX(va)];
	+ 		if(!(*table & PTEVALID)){
	+ 			panic("vunmap: not mapped");
	+ 			/* 
	+ 			va = (va+4*MB-1) & ~(4*MB-1);
	+ 			continue;
	+ 			*/
	+ 		}
	+ 		if(*table & PTESIZE){
	+ 			*table = 0;
	+ 			va = (va+4*MB-1) & ~(4*MB-1);
	+ 			continue;
	+ 		}
	+ 		table = KADDR(PPN(*table));
	+ 		if(!(table[PTX(va)] & PTEVALID))
	+ 			panic("vunmap: not mapped");
	+ 		table[PTX(va)] = 0;
	+ 		va += BY2PG;
	+ 	}
	+ }
	+ 
	+ /*
	+  * Handle a fault by bringing vmap up to date.
	+  * Only copy pdb entries and they never go away,
	+  * so no locking needed.
	+  */
	+ int
	+ vmapsync(ulong va)
	+ {
	+ 	ulong entry, *table;
	+ 
	+ 	if(va < VMAP || va >= VMAP+VMAPSIZE)
	+ 		return 0;
	+ 
	+ 	entry = MACHP(0)->pdb[PDX(va)];
	+ 	if(!(entry&PTEVALID))
	+ 		return 0;
	+ 	if(!(entry&PTESIZE)){
	+ 		/* make sure entry will help the fault */
	+ 		table = KADDR(PPN(entry));
	+ 		if(!(table[PTX(va)]&PTEVALID))
	+ 			return 0;
	+ 	}
	+ 	vpd[PDX(va)] = entry;
	  	/*
	- 	 * If something was added
	- 	 * then need to sync up.
	+ 	 * TLB doesn't cache negative results, so no flush needed.
	  	 */
	- 	if(sync)
	- 		mmukmapsync(ova);
	+ 	return 1;
	+ }
	  
	- 	return pa;
	+ 
	+ /*
	+  * KMap is used to map individual pages into virtual memory.
	+  * It is rare to have more than a few KMaps at a time (in the 
	+  * absence of interrupts, only two at a time are ever used,
	+  * but interrupts can stack).  The mappings are local to a process,
	+  * so we can use the same range of virtual address space for
	+  * all processes without any coordination.
	+  */
	+ #define kpt (vpt+VPTX(KMAP))
	+ #define NKPT (KMAPSIZE/BY2PG)
	+ 
	+ KMap*
	+ kmap(Page *page)
	+ {
	+ 	int i, o, s;
	+ 	Page *pdb;
	+ 
	+ 	if(up == nil)
	+ 		panic("kmap: up=0 pc=%#.8lux", getcallerpc(&page));
	+ 	if(up->mmupdb == nil)
	+ 		upallocpdb();
	+ 	if(!(vpd[PDX(KMAP)]&PTEVALID)){
	+ 		/* allocate page directory */
	+ 		if(KMAPSIZE > BY2XPG)
	+ 			panic("bad kmapsize");
	+ 		s = spllo();
	+ 		pdb = newpage(0, 0, 0);
	+ 		splx(s);
	+ 		vpd[PDX(KMAP)] = pdb->pa|PTEWRITE|PTEVALID;
	+ 		memset(kpt, 0, BY2PG);
	+ 
	+ 		/* might as well finish the job */
	+ 		kpt[0] = page->pa|PTEWRITE|PTEVALID;
	+ 		up->lastkmap = 0;
	+ 		return (KMap*)KMAP;
	+ 	}
	+ 	o = up->lastkmap+1;
	+ 	for(i=0; i<NKPT; i++){
	+ 		if(kpt[(i+o)%NKPT] == 0){
	+ 			o = (i+o)%NKPT;
	+ 			kpt[o] = page->pa|PTEWRITE|PTEVALID;
	+ 			up->lastkmap = o;
	+ 			return (KMap*)(KMAP+o*BY2PG);
	+ 		}
	+ 	}
	+ 	panic("out of kmap");
	+ 	return nil;
	+ }
	+ 
	+ void
	+ kunmap(KMap *k)
	+ {
	+ 	ulong va;
	+ 
	+ 	va = (ulong)k;
	+ 	if(up->mmupdb == nil || !(vpd[PDX(KMAP)]&PTEVALID))
	+ 		panic("kunmap: no kmaps");
	+ 	if(va < KMAP || va >= KMAP+KMAPSIZE)
	+ 		panic("kunmap: bad address %#.8lux pc=%#.8lux", va, getcallerpc(&k));
	+ 	if(!(vpt[VPTX(va)]&PTEVALID))
	+ 		panic("kunmap: not mapped %#.8lux pc=%#.8lux", va, getcallerpc(&k));
	+ 	vpt[VPTX(va)] = 0;
	+ 	flushpg(va);
	+ }
	+ 
	+ 
	+ /*
	+  * Temporary one-page mapping used to edit page directories.
	+  *
	+  * The fasttmp #define controls whether the code optimizes
	+  * the case where the page is already mapped in the physical
	+  * memory window.  
	+  */
	+ #define fasttmp 1
	+ 
	+ void*
	+ tmpmap(Page *p)
	+ {
	+ 	ulong i;
	+ 	ulong *entry;
	+ 	
	+ 	if(islo())
	+ 		panic("tmpaddr: islo");
	+ 
	+ 	if(fasttmp && p->pa < -KZERO)
	+ 		return KADDR(p->pa);
	+ 
	+ 	/*
	+ 	 * PDX(TMPADDR) == PDX(MACHADDR), so this
	+ 	 * entry is private to the processor and shared 
	+ 	 * between up->mmupdb (if any) and m->pdb.
	+ 	 */
	+ 	entry = &vpt[VPTX(TMPADDR)];
	+ 	if(!(*entry&PTEVALID)){
	+ 		for(i=KZERO; i<=CPU0MACH; i+=BY2PG)
	+ 			print("%.8lux: *%.8lux=%.8lux (vpt=%.8lux index=%.8lux)\n", i, &vpt[VPTX(i)], vpt[VPTX(i)], vpt, VPTX(i));
	+ 		panic("tmpmap: no entry");
	+ 	}
	+ 	if(PPN(*entry) != PPN(TMPADDR-KZERO))
	+ 		panic("tmpmap: already mapped entry=%#.8lux", *entry);
	+ 	*entry = p->pa|PTEWRITE|PTEVALID;
	+ 	flushpg(TMPADDR);
	+ 	return (void*)TMPADDR;
	+ }
	+ 
	+ void
	+ tmpunmap(void *v)
	+ {
	+ 	ulong *entry;
	+ 	
	+ 	if(islo())
	+ 		panic("tmpaddr: islo");
	+ 	if(fasttmp && (ulong)v >= KZERO && v != (void*)TMPADDR)
	+ 		return;
	+ 	if(v != (void*)TMPADDR)
	+ 		panic("tmpunmap: bad address");
	+ 	entry = &vpt[VPTX(TMPADDR)];
	+ 	if(!(*entry&PTEVALID) || PPN(*entry) == PPN(PADDR(TMPADDR)))
	+ 		panic("tmpmap: not mapped entry=%#.8lux", *entry);
	+ 	*entry = PPN(TMPADDR-KZERO)|PTEWRITE|PTEVALID;
	+ 	flushpg(TMPADDR);
	+ }
	+ 
	+ /*
	+  * These could go back to being macros once the kernel is debugged,
	+  * but the extra checking is nice to have.
	+  */
	+ void*
	+ kaddr(ulong pa)
	+ {
	+ 	if(pa > (ulong)-KZERO)
	+ 		panic("kaddr: pa=%#.8lux", pa);
	+ 	return (void*)(pa+KZERO);
	+ }
	+ 
	+ ulong
	+ paddr(void *v)
	+ {
	+ 	ulong va;
	+ 	
	+ 	va = (ulong)v;
	+ 	if(va < KZERO)
	+ 		panic("paddr: va=%#.8lux", va);
	+ 	return va-KZERO;
	  }
 [rsc] --rw-rw-r-- M 451989 glenda sys 17157 Nov  6 20:17 sys/src/9/pc/mp.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mp.c:137,142 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mp.c:137,143
	  mkioapic(PCMPioapic* p)
	  {
	  	Apic *apic;
	+ 	void *va;
	  
	  	if(!(p->flags & PcmpEN) || p->apicno > MaxAPICNO)
	  		return 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mp.c:144,156 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mp.c:145,157
	  	/*
	  	 * Map the I/O APIC.
	  	 */
	- 	if(mmukmap(p->addr, 0, 1024) == 0)
	+ 	if((va = vmap(p->addr, 1024)) == 0)
	  		return 0;
	  
	  	apic = &mpapic[p->apicno];
	  	apic->type = PcmpIOAPIC;
	  	apic->apicno = p->apicno;
	- 	apic->addr = KADDR(p->addr);
	+ 	apic->addr = va;
	  	apic->flags = p->flags;
	  
	  	return apic;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mp.c:440,445 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mp.c:441,449
	  	*p++ = PADDR(APBOOTSTRAP);
	  	*p++ = PADDR(APBOOTSTRAP)>>8;
	  	i = (PADDR(APBOOTSTRAP) & ~0xFFFF)/16;
	+ 	/* code assumes i==0 */
	+ 	if(i != 0)
	+ 		print("mp: bad APBOOTSTRAP\n");
	  	*p++ = i;
	  	*p = i>>8;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mp.c:465,470 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mp.c:469,475
	  	PCMP *pcmp;
	  	uchar *e, *p;
	  	Apic *apic, *bpapic;
	+ 	void *va;
	  
	  	i8259init();
	  	syncclock();
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mp.c:476,482 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mp.c:481,487
	  	/*
	  	 * Map the local APIC.
	  	 */
	- 	if(mmukmap(pcmp->lapicbase, 0, 1024) == 0)
	+ 	if((va = vmap(pcmp->lapicbase, 1024)) == nil)
	  		return;
	  
	  	bpapic = nil;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mp.c:508,514 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mp.c:513,519
	  			 * guarantee that the bootstrap processor appears
	  			 * first in the table before the others.
	  			 */
	- 			apic->addr = KADDR(pcmp->lapicbase);
	+ 			apic->addr = va;
	  			if(apic->flags & PcmpBP)
	  				bpapic = apic;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mp.c:766,772 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mp.c:771,777
	  		if(vno != -1)
	  			return vno;
	  	}
	- 
	+ 	print("mpintrenable: out of choices %d %d\n", mpeisabus, mpisabus);
	  	return -1;
	  }
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 6638 Nov  6 10:21 sys/src/9/pc/mp.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mp.h:217,222 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mp.h:217,224
	  extern int lapicisr(int);
	  extern int lapiceoi(int);
	  extern void lapicicrw(int, int);
	+ extern void lapicintron(void);
	+ extern void lapicintroff(void);
	  
	  extern void mpinit(void);
	  extern void mpshutdown(void);
 [rsc] --rw-rw-r-- M 451989 glenda sys 1427 Nov  6 10:21 sys/src/9/pc/pc
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pc:38,43 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pc:38,44
	  link
	  	devpccard
	  	devi82365
	+ 	realmode
	  	ether2000	ether8390
	  	ether2114x	pci
	  	ether589	etherelnk3
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pc:93,98 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pc:94,100
	  	vgat2r4		+cur
	  	vgatvp3020	=cur
	  	vgatvp3026	=cur
	+ 	vgavesa
	  	vgavmware	+cur
	  
	  ip
 [rsc] --rw-rw-r-- M 451989 glenda sys 714 Nov  6 10:21 sys/src/9/pc/pcauth
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pcauth:37,42 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pcauth:37,43
	  	loopbackmedium
	  
	  misc
	+ 	realmode
	  	sdata		pci sdscsi
	  
	  	uarti8250
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pcauth:43,49 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pcauth:44,50
	  	uartpci
	  
	  	vgamach64xx	+cur
	- 	vgas3  +cur vgasavage
	+ 	vgas3 		+cur vgasavage
	  
	  ip
	  	il
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pcauth:65,68 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pcauth:66,71
	  	bootpcauth.out boot
	  	/386/bin/ip/ipconfig
	  	/386/bin/auth/factotum
	+ 	/386/bin/fossil/fossil
	+ 	/386/bin/venti/venti
	  	/386/bin/disk/kfs
 [rsc] --rw-rw-r-- M 451989 glenda sys 866 Nov  6 10:21 sys/src/9/pc/pccpu
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pccpu:28,33 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pccpu:28,34
	  	usb
	  
	  link
	+ 	realmode
	  	ether2000	ether8390
	  	ether2114x	pci
	  	ether79c970	pci
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pccpu:53,58 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pccpu:54,60
	  
	  	sdata		pci sdscsi
	  	sd53c8xx	pci sdscsi
	+ 	sdmv50xx	pci sdscsi
	  
	  
	  ip
 [rsc] --rw-rw-r-- M 451989 glenda sys 1446 Nov  6 12:59 sys/src/9/pc/pcdisk
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pcdisk:60,65 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pcdisk:60,66
	  	usbuhci
	  
	  misc
	+ 	realmode
	  	archmp		mp apic
	  
	  	sdata		pci sdscsi
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pcdisk:89,94 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pcdisk:90,96
	  	vgat2r4		+cur
	  	vgatvp3020	=cur
	  	vgatvp3026	=cur
	+ 	vgavesa
	  	vgavmware	+cur
	  
	  ip
 [rsc] --rw-rw-r-- M 451989 presotto sys 1504 Nov  6 12:59 sys/src/9/pc/pcf
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pcf:62,67 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pcf:62,68
	  	usbuhci
	  
	  misc
	+ 	realmode
	  	archmp		mp apic
	  
	  	sdata		pci sdscsi
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pcf:91,96 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pcf:92,98
	  	vgat2r4		+cur
	  	vgatvp3020	=cur
	  	vgatvp3026	=cur
	+ 	vgavesa
	  	vgavmware	+cur
	  
	  ip
 [rsc] --rw-rw-r-- M 451989 glenda sys 26817 Nov  6 10:21 sys/src/9/pc/pci.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pci.c:759,764 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pci.c:759,766
	  	}
	  }
	  
	+ static void pcireservemem(void);
	+ 
	  static void
	  pcicfginit(void)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pci.c:898,907 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pci.c:900,926
	  		pcirouting();
	  
	  out:
	+ 	pcireservemem();
	  	unlock(&pcicfginitlock);
	  
	  	if(getconf("*pcihinv"))
	  		pcihinv(nil);
	+ }
	+ 
	+ static void
	+ pcireservemem(void)
	+ {
	+ 	int i;
	+ 	Pcidev *p;
	+ 	
	+ 	/*
	+ 	 * mark all the physical address space claimed by pci devices
	+ 	 * as in use, so that upaalloc doesn't give it out.
	+ 	 */
	+ 	for(p=pciroot; p; p=p->list)
	+ 		for(i=0; i<nelem(p->mem); i++)
	+ 			if(p->mem[i].bar && (p->mem[i].bar&1) == 0)
	+ 				upareserve(p->mem[i].bar&~0x0F, p->mem[i].size);
	  }
	  
	  static int
 [rsc] --rw-rw-r-- M 451989 glenda sys 13460 Nov  6 10:21 sys/src/9/pc/screen.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.c:38,48 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.c:38,51
	  	},
	  };
	  
	+ int didswcursorinit;
	+ 
	  int
	  screensize(int x, int y, int z, ulong chan)
	  {
	  	VGAscr *scr;
	  
	+ 	lock(&vgascreenlock);
	  	memimageinit();
	  	scr = &vgascreen[0];
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.c:50,56 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.c:53,59
	  	 * BUG: need to check if any xalloc'ed memory needs to
	  	 * be given back if aperture is set.
	  	 */
	- 	if(scr->aperture == 0){
	+ 	if(scr->paddr == 0){
	  		int width = (x*z)/BI2WD;
	  
	  		gscreendata.bdata = xalloc(width*BY2WD*y);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.c:58,76 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.c:61,83
	  			error("screensize: vga soft memory");
	  /*		memset(gscreendata.bdata, 0x72, width*BY2WD*y);	/* not really black */
	  		scr->useflush = 1;
	- 		scr->aperture = VGAMEM();
	+ 		scr->paddr = VGAMEM();
	+ 		scr->vaddr = KADDR(scr->paddr);
	  		scr->apsize = 1<<16;
	  	}
	  	else
	- 		gscreendata.bdata = KADDR(scr->aperture);
	+ 		gscreendata.bdata = scr->vaddr;
	  
	  	if(gscreen)
	  		freememimage(gscreen);
	+ 	scr->gscreen = nil;
	  
	  	gscreen = allocmemimaged(Rect(0,0,x,y), chan, &gscreendata);
	  	vgaimageinit(chan);
	- 	if(gscreen == nil)
	+ 	if(gscreen == nil){
	+ 		unlock(&vgascreenlock);
	  		return -1;
	+ 	}
	  
	  	if(scr->dev && scr->dev->flush)
	  		scr->useflush = 1;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.c:81,87 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.c:88,97
	  	scr->gscreen = gscreen;
	  
	  	physgscreenr = gscreen->r;
	+ 	unlock(&vgascreenlock);
	  
	+ 	if(didswcursorinit)
	+ 		swcursorinit();
	  	drawcmap();
	  	return 0;
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.c:90,121 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.c:100,130
	  screenaperture(int size, int align)
	  {
	  	VGAscr *scr;
	- 	ulong aperture;
	  
	  	scr = &vgascreen[0];
	  
	- 	if(size == 0){
	- 		if(scr->aperture && scr->isupamem)
	- 			upafree(scr->aperture, scr->apsize);
	- 		scr->aperture = 0;
	- 		scr->isupamem = 0;
	+ 	if(scr->paddr)	/* set up during enable */
	  		return 0;
	- 	}
	- 	if(scr->dev && scr->dev->linear){
	- 		aperture = scr->dev->linear(scr, &size, &align);
	- 		if(aperture == 0)
	- 			return 1;
	- 	}else{
	- 		aperture = upamalloc(0, size, align);
	- 		if(aperture == 0)
	- 			return 1;
	  
	- 		if(scr->aperture && scr->isupamem)
	- 			upafree(scr->aperture, scr->apsize);
	- 		scr->isupamem = 1;
	+ 	if(size == 0)
	+ 		return 0;
	+ 
	+ 	if(scr->dev && scr->dev->linear){
	+ 		scr->dev->linear(scr, size, align);
	+ 		return 0;
	  	}
	  
	- 	scr->aperture = aperture;
	+ 	/*
	+ 	 * Need to allocate some physical address space.
	+ 	 * The driver will tell the card to use it.
	+ 	 */
	+ 	size = PGROUND(size);
	+ 	scr->paddr = upaalloc(size, align);
	+ 	if(scr->paddr == 0)
	+ 		return -1;
	+ 	scr->vaddr = vmap(scr->paddr, size);
	+ 	if(scr->vaddr == nil)
	+ 		return -1;
	  	scr->apsize = size;
	  
	  	return 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.c:179,185 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.c:188,194
	  	off = r.min.y*scr->gscreen->width*BY2WD+(r.min.x*scr->gscreen->depth)/8;
	  	page = off/scr->apsize;
	  	off %= scr->apsize;
	- 	disp = KADDR(scr->aperture);
	+ 	disp = scr->vaddr;
	  	sdisp = disp+off;
	  	edisp = disp+scr->apsize;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.c:339,355 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.c:348,376
	  hwdraw(Memdrawparam *par)
	  {
	  	VGAscr *scr;
	- 	Memimage *dst, *src;
	+ 	Memimage *dst, *src, *mask;
	  	int m;
	  
	  	if(hwaccel == 0)
	  		return 0;
	  
	- 	dst = par->dst;
	  	scr = &vgascreen[0];
	- 	if(dst == nil || dst->data == nil)
	+ 	if((dst=par->dst) == nil || dst->data == nil)
	  		return 0;
	+ 	if((src=par->src) == nil || src->data == nil)
	+ 		return 0;
	+ 	if((mask=par->mask) == nil || mask->data == nil)
	+ 		return 0;
	  
	+ 	if(scr->cur == &swcursor){
	+ 		if(dst->data->bdata == gscreendata.bdata)
	+ 			swcursoravoid(par->r);
	+ 		if(src->data->bdata == gscreendata.bdata)
	+ 			swcursoravoid(par->sr);
	+ 		if(mask->data->bdata == gscreendata.bdata)
	+ 			swcursoravoid(par->mr);
	+ 	}
	+ 	
	  	if(dst->data->bdata != gscreendata.bdata)
	  		return 0;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.c:374,380 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.c:395,400
	  	 * the source is not replicated, memmove suffices.
	  	 */
	  	m = Simplemask|Fullmask;
	- 	src = par->src;
	  	if(scr->scroll
	  	&& src->data->bdata==dst->data->bdata
	  	&& !(src->flags&Falpha)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.c:398,400 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.c:418,711
	  			vgablank(scr, blank);
	  	}
	  }
	+ 
	+ void
	+ vgalinearpciid(VGAscr *scr, int vid, int did)
	+ {
	+ 	Pcidev *p;
	+ 
	+ 	p = nil;
	+ 	while((p = pcimatch(p, vid, 0)) != nil){
	+ 		if(p->ccrb != 3)	/* video card */
	+ 			continue;
	+ 		if(did != 0 && p->did != did)
	+ 			continue;
	+ 		break;
	+ 	}
	+ 	if(p == nil)
	+ 		error("pci video card not found");
	+ 
	+ 	scr->pci = p;
	+ 	vgalinearpci(scr);
	+ }
	+ 
	+ void
	+ vgalinearpci(VGAscr *scr)
	+ {
	+ 	ulong paddr;
	+ 	int i, size, best;
	+ 	Pcidev *p;
	+ 	
	+ 	p = scr->pci;
	+ 	if(p == nil)
	+ 		return;
	+ 
	+ 	/*
	+ 	 * Scan for largest memory region on card.
	+ 	 * Some S3 cards (e.g. Savage) have enormous
	+ 	 * mmio regions (but even larger frame buffers).
	+ 	 */
	+ 	best = -1;
	+ 	for(i=0; i<nelem(p->mem); i++){
	+ 		if(p->mem[i].bar&1)	/* not memory */
	+ 			continue;
	+ 		if(p->mem[i].size < 640*480)	/* not big enough */
	+ 			continue;
	+ 		if(best==-1 || p->mem[i].size > p->mem[best].size)
	+ 			best = i;
	+ 	}
	+ 	if(best >= 0){
	+ 		paddr = p->mem[best].bar & ~0x0F;
	+ 		size = p->mem[best].size;
	+ 		vgalinearaddr(scr, paddr, size);
	+ 		return;
	+ 	}
	+ 	error("no video memory found on pci card");
	+ }
	+ 
	+ void
	+ vgalinearaddr(VGAscr *scr, ulong paddr, int size)
	+ {
	+ 	int x, nsize;
	+ 	ulong npaddr;
	+ 
	+ 	/*
	+ 	 * new approach.  instead of trying to resize this
	+ 	 * later, let's assume that we can just allocate the
	+ 	 * entire window to start with.
	+ 	 */
	+ 
	+ 	if(scr->paddr == paddr && size <= scr->apsize)
	+ 		return;
	+ 
	+ 	if(scr->paddr){
	+ 		/*
	+ 		 * could call vunmap and vmap,
	+ 		 * but worried about dangling pointers in devdraw
	+ 		 */
	+ 		error("cannot grow vga frame buffer");
	+ 	}
	+ 	
	+ 	/* round to page boundary, just in case */
	+ 	x = paddr&(BY2PG-1);
	+ 	npaddr = paddr-x;
	+ 	nsize = PGROUND(size+x);
	+ 
	+ 	scr->vaddr = vmap(npaddr, nsize);
	+ 	if(scr->vaddr == 0)
	+ 		error("cannot allocate vga frame buffer");
	+ 	scr->vaddr = (char*)scr->vaddr+x;
	+ 	scr->paddr = paddr;
	+ 	scr->apsize = nsize;
	+ }
	+ 
	+ 
	+ /*
	+  * Software cursor. 
	+  */
	+ int	swvisible;	/* is the cursor visible? */
	+ int	swenabled;	/* is the cursor supposed to be on the screen? */
	+ Memimage*	swback;	/* screen under cursor */
	+ Memimage*	swimg;	/* cursor image */
	+ Memimage*	swmask;	/* cursor mask */
	+ Memimage*	swimg1;
	+ Memimage*	swmask1;
	+ 
	+ Point	swoffset;
	+ Rectangle	swrect;	/* screen rectangle in swback */
	+ Point	swpt;	/* desired cursor location */
	+ Point	swvispt;	/* actual cursor location */
	+ int	swvers;	/* incremented each time cursor image changes */
	+ int	swvisvers;	/* the version on the screen */
	+ 
	+ /*
	+  * called with drawlock locked for us, most of the time.
	+  * kernel prints at inopportune times might mean we don't
	+  * hold the lock, but memimagedraw is now reentrant so
	+  * that should be okay: worst case we get cursor droppings.
	+  */
	+ void
	+ swcursorhide(void)
	+ {
	+ 	if(swvisible == 0)
	+ 		return;
	+ 	if(swback == nil)
	+ 		return;
	+ 	swvisible = 0;
	+ 	memimagedraw(gscreen, swrect, swback, ZP, memopaque, ZP, S);
	+ }
	+ 
	+ void
	+ swcursoravoid(Rectangle r)
	+ {
	+ 	if(swvisible && rectXrect(r, swrect))
	+ 		swcursorhide();
	+ }
	+ 
	+ void
	+ swcursordraw(void)
	+ {
	+ 	if(swvisible)
	+ 		return;
	+ 	if(swenabled == 0)
	+ 		return;
	+ 	if(swback == nil || swimg1 == nil || swmask1 == nil)
	+ 		return;
	+ 	assert(!canqlock(&drawlock));
	+ 	swvispt = swpt;
	+ 	swvisvers = swvers;
	+ 	swrect = rectaddpt(Rect(0,0,16,16), swvispt);
	+ 	memimagedraw(swback, swback->r, gscreen, swpt, memopaque, ZP, S);
	+ 	memimagedraw(gscreen, swrect, swimg1, ZP, swmask1, ZP, SoverD);
	+ 	swvisible = 1;
	+ }
	+ 
	+ /*
	+  * Need to lock drawlock for ourselves.
	+  */
	+ void
	+ swenable(VGAscr*)
	+ {
	+ 	swenabled = 1;
	+ 	if(canqlock(&drawlock)){
	+ 		swcursordraw();
	+ 		qunlock(&drawlock);
	+ 	}
	+ }
	+ 
	+ void
	+ swdisable(VGAscr*)
	+ {
	+ 	swenabled = 0;
	+ 	if(canqlock(&drawlock)){
	+ 		swcursorhide();
	+ 		qunlock(&drawlock);
	+ 	}
	+ }
	+ 
	+ void
	+ swload(VGAscr*, Cursor *curs)
	+ {
	+ 	uchar *ip, *mp;
	+ 	int i, j, set, clr;
	+ 
	+ 	if(!swimg || !swmask || !swimg1 || !swmask1)
	+ 		return;
	+ 	/*
	+ 	 * Build cursor image and mask.
	+ 	 * Image is just the usual cursor image
	+ 	 * but mask is a transparent alpha mask.
	+ 	 * 
	+ 	 * The 16x16x8 memimages do not have
	+ 	 * padding at the end of their scan lines.
	+ 	 */
	+ 	ip = byteaddr(swimg, ZP);
	+ 	mp = byteaddr(swmask, ZP);
	+ 	for(i=0; i<32; i++){
	+ 		set = curs->set[i];
	+ 		clr = curs->clr[i];
	+ 		for(j=0x80; j; j>>=1){
	+ 			*ip++ = set&j ? 0x00 : 0xFF;
	+ 			*mp++ = (clr|set)&j ? 0xFF : 0x00;
	+ 		}
	+ 	}
	+ 	swoffset = curs->offset;
	+ 	swvers++;
	+ 	memimagedraw(swimg1, swimg1->r, swimg, ZP, memopaque, ZP, S);
	+ 	memimagedraw(swmask1, swmask1->r, swmask, ZP, memopaque, ZP, S);
	+ }
	+ 
	+ int
	+ swmove(VGAscr*, Point p)
	+ {
	+ 	swpt = addpt(p, swoffset);
	+ 	return 0;
	+ }
	+ 
	+ void
	+ swcursorclock(void)
	+ {
	+ 	int x;
	+ 
	+ 	if(!swenabled)
	+ 		return;
	+ 	if(swvisible && eqpt(swpt, swvispt) && swvers==swvisvers)
	+ 		return;
	+ 
	+ 	x = splhi();
	+ 	if(swenabled)
	+ 	if(!swvisible || !eqpt(swpt, swvispt) || swvers!=swvisvers)
	+ 	if(canqlock(&drawlock)){
	+ 		swcursorhide();
	+ 		swcursordraw();
	+ 		qunlock(&drawlock);
	+ 	}
	+ 	splx(x);
	+ }
	+ 
	+ void
	+ swcursorinit(void)
	+ {
	+ 	static int init, warned;
	+ 	VGAscr *scr;
	+ 
	+ 	didswcursorinit = 1;
	+ 	if(!init){
	+ 		init = 1;
	+ 		addclock0link(swcursorclock, 50);
	+ 	}
	+ 	scr = &vgascreen[0];
	+ 	if(scr==nil || scr->gscreen==nil)
	+ 		return;
	+ 
	+ 	if(scr->dev == nil || scr->dev->linear == nil){
	+ 		if(!warned){
	+ 			print("cannot use software cursor on non-linear vga screen\n");
	+ 			warned = 1;
	+ 		}
	+ 		return;
	+ 	}
	+ 
	+ 	if(swback){
	+ 		freememimage(swback);
	+ 		freememimage(swmask);
	+ 		freememimage(swmask1);
	+ 		freememimage(swimg);
	+ 		freememimage(swimg1);
	+ 	}
	+ 
	+ 	swback = allocmemimage(Rect(0,0,32,32), gscreen->chan);
	+ 	swmask = allocmemimage(Rect(0,0,16,16), GREY8);
	+ 	swmask1 = allocmemimage(Rect(0,0,16,16), GREY1);
	+ 	swimg = allocmemimage(Rect(0,0,16,16), GREY8);
	+ 	swimg1 = allocmemimage(Rect(0,0,16,16), GREY1);
	+ 	if(swback==nil || swmask==nil || swmask1==nil || swimg==nil || swimg1 == nil){
	+ 		print("software cursor: allocmemimage: %r");
	+ 		return;
	+ 	}
	+ 
	+ 	memfillcolor(swmask, DOpaque);
	+ 	memfillcolor(swmask1, DOpaque);
	+ 	memfillcolor(swimg, DBlack);
	+ 	memfillcolor(swimg1, DBlack);
	+ }
	+ 
	+ VGAcur swcursor =
	+ {
	+ 	"soft",
	+ 	swenable,
	+ 	swdisable,
	+ 	swload,
	+ 	swmove,
	+ };
	+ 
 [rsc] --rw-rw-r-- M 451989 glenda sys 4156 Nov  6 10:21 sys/src/9/pc/screen.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.h:67,73 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.h:67,73
	  	void	(*enable)(VGAscr*);
	  	void	(*disable)(VGAscr*);
	  	void	(*page)(VGAscr*, int);
	- 	ulong	(*linear)(VGAscr*, int*, int*);
	+ 	void	(*linear)(VGAscr*, int, int);
	  	void	(*drawinit)(VGAscr*);
	  	int	(*fill)(VGAscr*, Rectangle, ulong);
	  	void	(*ovlctl)(VGAscr*, Chan*, void*, int);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.h:91,96 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.h:91,97
	  struct VGAscr {
	  	Lock	devlock;
	  	VGAdev*	dev;
	+ 	Pcidev*	pci;
	  
	  	VGAcur*	cur;
	  	ulong	storage;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.h:98,113 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.h:99,114
	  
	  	int	useflush;
	  
	- 	ulong	aperture;			/* physical address */
	- 	int	isupamem;
	- 	int	apsize;
	+ 	ulong	paddr;		/* frame buffer */
	+ 	void*	vaddr;
	+ 	int		apsize;
	  
	  	ulong	io;				/* device specific registers */
	- 
	+ 	ulong	*mmio;
	+ 	
	  	ulong	colormap[Pcolours][3];
	  	int	palettedepth;
	  
	- 	ulong	*mmio;
	  	Memimage* gscreen;
	  	Memdata* gscreendata;
	  	Memsubfont* memdefont;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.h:128,133 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.h:129,135
	  
	  /* mouse.c */
	  extern void mousectl(Cmdbuf*);
	+ extern void mouseresize(void);
	  
	  /* screen.c */
	  extern int		hwaccel;	/* use hw acceleration; default on */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/screen.h:144,161 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/screen.h:146,179
	  extern Rectangle physgscreenr;	/* actual monitor size */
	  extern void	blankscreen(int);
	  
	+ extern VGAcur swcursor;
	+ extern void swcursorinit(void);
	+ extern void swcursorhide(void);
	+ extern void swcursoravoid(Rectangle);
	+ extern void swcursorunhide(void);
	+ 
	  /* devdraw.c */
	  extern void	deletescreenimage(void);
	+ extern void	resetscreenimage(void);
	  extern int		drawhasclients(void);
	  extern ulong	blanktime;
	  extern void	setscreenimageclipr(Rectangle);
	  extern void	drawflush(void);
	  extern int drawidletime(void);
	+ extern QLock	drawlock;
	  
	  /* vga.c */
	  extern void	vgascreenwin(VGAscr*);
	  extern void	vgaimageinit(ulong);
	- extern ulong	vgapcilinear(VGAscr*, int*, int*, int, int);
	+ extern void	vgalinearpciid(VGAscr*, int, int);
	+ extern void	vgalinearpci(VGAscr*);
	+ extern void	vgalinearaddr(VGAscr*, ulong, int);
	  
	  extern void	drawblankscreen(int);
	  extern void	vgablank(VGAscr*, int);
	+ 
	+ extern Lock	vgascreenlock;
	+ 
	+ 
	+ 
	+ 
 [rsc] --rw-rw-r-- M 451989 glenda sys 55206 Nov  6 10:22 sys/src/9/pc/sd53c8xx.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:52,59 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:52,60
	  
	  #else
	  
	- #define KPRINT	if(0) print
	- #define IPRINT	if(0) print
	+ static int idebug = 1;
	+ #define KPRINT	if(0) iprint
	+ #define IPRINT	if(idebug) iprint
	  #define DEBUG(n)	(0)
	  #define IFLUSH()
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:304,310 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:305,310
	  	struct {
	  		Lock;
	  		uchar head[4];		/* head of free list (NCR byte order) */
	- 		Dsa	*tail;
	  		Dsa	*freechain;
	  	} dsalist;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:383,388 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:383,417
	  
	  #include "sd53c8xx.i"
	  
	+ /*
	+  * We used to use a linked list of Dsas with nil as the terminator,
	+  * but occasionally the 896 card seems not to notice that the 0
	+  * is really a 0, and then it tries to reference the Dsa at address 0.
	+  * To address this, we use a sentinel dsa that links back to itself
	+  * and has state A_STATE_END.  If the card takes an iteration or
	+  * two to notice that the state says A_STATE_END, that's no big 
	+  * deal.  Clearly this isn't the right approach, but I'm just
	+  * stumped.  Even with this, we occasionally get prints about
	+  * "WSR set", usually with about the same frequency that the
	+  * card used to walk past 0. 
	+  */
	+ static Dsa *dsaend;
	+ 
	+ static Dsa*
	+ dsaallocnew(Controller *c)
	+ {
	+ 	Dsa *d;
	+ 	
	+ 	/* c->dsalist must be ilocked */
	+ 	d = xalloc(sizeof *d);
	+ 	lesetl(d->next, legetl(c->dsalist.head));
	+ 	lesetl(&d->stateb, A_STATE_FREE);
	+ 	coherence();
	+ 	lesetl(c->dsalist.head, DMASEG(d));
	+ 	coherence();
	+ 	return d;
	+ }
	+ 
	  static Dsa *
	  dsaalloc(Controller *c, int target, int lun)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:389,414 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:418,433
	  	Dsa *d;
	  
	  	ilock(&c->dsalist);
	- 	if ((d = c->dsalist.freechain) == 0) {
	- 		d = xalloc(sizeof(*d));
	- 		if (DEBUG(1)) {
	- 			KPRINT(PRINTPREFIX "%d/%d: allocated new dsa %lux\n", target, lun, (ulong)d);
	- 		}
	- 		lesetl(d->next, 0);
	- 		lesetl(&d->stateb, A_STATE_ALLOCATED);
	- 		if (legetl(c->dsalist.head) == 0)
	- 			lesetl(c->dsalist.head, DMASEG(d));	/* ATOMIC?!? */
	- 		else
	- 			lesetl(c->dsalist.tail->next, DMASEG(d));	/* ATOMIC?!? */
	- 		c->dsalist.tail = d;
	+ 	if ((d = c->dsalist.freechain) != 0) {
	+ 		if (DEBUG(1))
	+ 			IPRINT(PRINTPREFIX "%d/%d: reused dsa %lux\n", target, lun, (ulong)d);
	+ 	} else {	
	+ 		d = dsaallocnew(c);
	+ 		if (DEBUG(1))
	+ 			IPRINT(PRINTPREFIX "%d/%d: allocated dsa %lux\n", target, lun, (ulong)d);
	  	}
	- 	else {
	- 		if (DEBUG(1)) {
	- 			KPRINT(PRINTPREFIX "%d/%d: reused dsa %lux\n", target, lun, (ulong)d);
	- 		}
	- 		c->dsalist.freechain = d->freechain;
	- 		lesetl(&d->stateb, A_STATE_ALLOCATED);
	- 	}
	+ 	c->dsalist.freechain = d->freechain;
	+ 	lesetl(&d->stateb, A_STATE_ALLOCATED);
	  	iunlock(&c->dsalist);
	  	d->target = target;
	  	d->lun = lun;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:425,435 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:444,493
	  	iunlock(&c->dsalist);
	  }
	  
	+ static void
	+ dsadump(Controller *c)
	+ {
	+ 	Dsa *d;
	+ 	u32int *a;
	+ 	
	+ 	iprint("dsa controller list: c=%p head=%.8lux\n", c, legetl(c->dsalist.head));
	+ 	for(d=KPTR(legetl(c->dsalist.head)); d != dsaend; d=KPTR(legetl(d->next))){
	+ 		if(d == (void*)-1){
	+ 			iprint("\t dsa %p\n", d);
	+ 			break;
	+ 		}
	+ 		a = (u32int*)d;
	+ 		iprint("\tdsa %p %.8ux %.8ux %.8ux %.8ux %.8ux %.8ux\n", a, a[0], a[1], a[2], a[3], a[4], a[5]);
	+ 	}
	+ 
	+ /*
	+ 	a = KPTR(c->scriptpa+E_dsa_addr);
	+ 	iprint("dsa_addr: %.8ux %.8ux %.8ux %.8ux %.8ux\n",
	+ 		a[0], a[1], a[2], a[3], a[4]);
	+ 	a = KPTR(c->scriptpa+E_issue_addr);
	+ 	iprint("issue_addr: %.8ux %.8ux %.8ux %.8ux %.8ux\n",
	+ 		a[0], a[1], a[2], a[3], a[4]);
	+ 
	+ 	a = KPTR(c->scriptpa+E_issue_test_begin);
	+ 	e = KPTR(c->scriptpa+E_issue_test_end);
	+ 	iprint("issue_test code (at offset %.8ux):\n", E_issue_test_begin);
	+ 	
	+ 	i = 0;
	+ 	for(; a<e; a++){
	+ 		iprint(" %.8ux", *a);
	+ 		if(++i%8 == 0)
	+ 			iprint("\n");
	+ 	}
	+ 	if(i%8)
	+ 		iprint("\n");
	+ */
	+ }
	+ 
	  static Dsa *
	  dsafind(Controller *c, uchar target, uchar lun, uchar state)
	  {
	  	Dsa *d;
	- 	for (d = KPTR(legetl(c->dsalist.head)); d; d = KPTR(legetl(d->next))) {
	+ 	for (d = KPTR(legetl(c->dsalist.head)); d != dsaend; d = KPTR(legetl(d->next))) {
	  		if (d->target != 0xff && d->target != target)
	  			continue;
	  		if (lun != 0xff && d->lun != lun)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:764,769 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:822,828
	  	c->running = 1;
	  	p = c->scriptpa + entry;
	  	lesetl(c->n->dsp, p);
	+ 	coherence();
	  	if (c->ssm)
	  		c->n->dcntl |= 0x4;		/* start DMA in SSI mode */
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:775,780 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:834,840
	  		panic(PRINTPREFIX "ncrcontinue called while running");
	  	/* set the start DMA bit to continue execution */
	  	c->running = 1;
	+ 	coherence();
	  	c->n->dcntl |= 0x4;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1126,1131 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1186,1192
	  	int wakeme = 0;
	  	int cont = -1;
	  	Dsa *dsa;
	+ 	ulong dsapa;
	  	Controller *c = a;
	  	Ncr *n = c->n;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1143,1149 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1204,1210
	  		}
	  		n->istat = Intf;
	  		/* search for structures in A_STATE_DONE */
	- 		for (d = KPTR(legetl(c->dsalist.head)); d; d = KPTR(legetl(d->next))) {
	+ 		for (d = KPTR(legetl(c->dsalist.head)); d != dsaend; d = KPTR(legetl(d->next))) {
	  			if (d->stateb == A_STATE_DONE) {
	  				d->p9status = d->status;
	  				if (DEBUG(1)) {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1168,1174 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1229,1253
	  
	  	sist = (n->sist1<<8)|n->sist0;	/* BUG? can two-byte read be inconsistent? */
	  	dstat = n->dstat;
	- 	dsa = (Dsa *)DMASEG_TO_KADDR(legetl(n->dsa));
	+ 	dsapa = legetl(n->dsa);
	+ 
	+ 	/*
	+ 	 * Can't compute dsa until we know that dsapa is valid.
	+ 	 */
	+ 	if(dsapa < -KZERO)
	+ 		dsa = (Dsa*)DMASEG_TO_KADDR(dsapa);
	+ 	else{
	+ 		dsa = nil;
	+ 		/*
	+ 		 * happens at startup on some cards but we 
	+ 		 * don't actually deref dsa because none of the
	+ 		 * flags we are about are set.
	+ 		 * still, print in case that changes and we're
	+ 		 * about to dereference nil.
	+ 		 */
	+ 		iprint("sd53c8xxinterrupt: dsa=%.8lux istat=%ux sist=%ux dstat=%ux\n", dsapa, istat, sist, dstat);
	+ 	}
	+ 
	  	c->running = 0;
	  	if (istat & Sip) {
	  		if (DEBUG(1)) {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1315,1320 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1394,1400
	  			}
	  			dsa->p9status = SDtimeout;
	  			dsa->stateb = A_STATE_DONE;
	+ 			coherence();
	  			softreset(c);
	  			cont = E_issue_check;
	  			wakeme = 1;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1336,1343 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1416,1422
	  			IPRINT("dstat = %.2x\n", dstat);
	  		}
	  		/*else*/ if (dstat & Ssi) {
	- 			ulong *p = DMASEG_TO_KADDR(legetl(n->dsp));
	- 			ulong w = (uchar *)p - (uchar *)c->script;
	+ 			ulong w = legetl(n->dsp) - c->scriptpa;
	  			IPRINT("[%lux]", w);
	  			USED(w);
	  			cont = -2;	/* restart */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1375,1380 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1454,1468
	  				dumpncrregs(c, 1);
	  				wakeme = 1;
	  				break;
	+ 			case A_SIR_NOTIFY_LOAD_STATE:
	+ 				IPRINT(PRINTPREFIX ": load_state dsa=%p\n", dsa);
	+ 				if (dsa == (void*)KZERO || dsa == (void*)-1) {
	+ 					dsadump(c);
	+ 					dumpncrregs(c, 1);
	+ 					panic("bad dsa in load_state");
	+ 				}
	+ 				cont = -2;
	+ 				break;
	  			case A_SIR_NOTIFY_MSG_IN:
	  				IPRINT(PRINTPREFIX "%d/%d: msg_in %d\n",
	  				    dsa->target, dsa->lun, n->sfbr);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1431,1437 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1519,1525
	  				cont = -2;
	  				break;
	  			case A_SIR_NOTIFY_ISSUE:
	- 				IPRINT(PRINTPREFIX "%d/%d: issue:", dsa->target, dsa->lun);
	+ 				IPRINT(PRINTPREFIX "%d/%d: issue dsa=%p end=%p:", dsa->target, dsa->lun, dsa, dsaend);
	  			dsadump:
	  				IPRINT(" tgt=%d", dsa->target);
	  				IPRINT(" time=%ld", TK2MS(m->ticks));
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1447,1453 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1535,1541
	  				cont = -2;
	  				break;
	  			case A_SIR_NOTIFY_DUMP_NEXT_CODE: {
	- 				ulong *dsp = DMASEG_TO_KADDR(legetl(n->dsp));
	+ 				ulong *dsp = c->script + (legetl(n->dsp)-c->scriptpa)/4;
	  				int x;
	  				IPRINT(PRINTPREFIX "code at %lux", dsp - c->script);
	  				for (x = 0; x < 6; x++) {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1475,1483 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1563,1571
	  				cont = -2;
	  				break;
	  			case A_error_reselected:		/* dsa isn't valid here */
	- 				print(PRINTPREFIX "reselection error\n");
	+ 				iprint(PRINTPREFIX "reselection error\n");
	  				dumpncrregs(c, 1);
	- 				for (dsa = KPTR(legetl(c->dsalist.head)); dsa; dsa = KPTR(legetl(dsa->next))) {
	+ 				for (dsa = KPTR(legetl(c->dsalist.head)); dsa != dsaend; dsa = KPTR(legetl(dsa->next))) {
	  					IPRINT(PRINTPREFIX "dsa target %d lun %d state %d\n", dsa->target, dsa->lun, dsa->stateb);
	  				}
	  				break;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1489,1503 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1577,1616
	  			}
	  		}
	  		/*else*/ if (dstat & Iid) {
	- 			ulong addr = legetl(n->dsp);
	- 			ulong dbc = (n->dbc[2]<<16)|(n->dbc[1]<<8)|n->dbc[0];
	+ 			int i, target, lun;
	+ 			ulong addr, dbc, *v;
	+ 			
	+ 			addr = legetl(n->dsp);
	+ 			if(dsa){
	+ 				target = dsa->target;
	+ 				lun = dsa->lun;
	+ 			}else{
	+ 				target = -1;
	+ 				lun = -1;
	+ 			}
	+ 			dbc = (n->dbc[2]<<16)|(n->dbc[1]<<8)|n->dbc[0];
	+ 
	+ 		//	if(dsa == nil)
	+ 				idebug++;
	  			IPRINT(PRINTPREFIX "%d/%d: Iid pa=%.8lux sa=%.8lux dbc=%lux\n",
	- 			    dsa->target, dsa->lun,
	+ 			    target, lun,
	  			    addr, addr - c->scriptpa, dbc);
	- 			addr = (ulong)DMASEG_TO_KADDR(addr);
	- 			IPRINT("%.8lux %.8lux %.8lux\n",
	- 			    *(ulong *)(addr - 12), *(ulong *)(addr - 8), *(ulong *)(addr - 4));
	+ 			addr = (ulong)c->script + addr - c->scriptpa;
	+ 			addr -= 64;
	+ 			addr &= ~63;
	+ 			v = (ulong*)addr;
	+ 			for(i=0; i<8; i++){
	+ 				IPRINT("%.8lux: %.8lux %.8lux %.8lux %.8lux\n", 
	+ 					addr, v[0], v[1], v[2], v[3]);
	+ 				addr += 4*4;
	+ 				v += 4;
	+ 			}
	  			USED(addr, dbc);
	+ 			if(dsa == nil){
	+ 				dsadump(c);
	+ 				dumpncrregs(c, 1);
	+ 				panic("bad dsa");
	+ 			}
	  			dsa->p9status = SDeio;
	  			wakeme = 1;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1634,1639 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1747,1753
	  
	  	if((target = r->unit->subno) == 0x07)
	  		return r->status = SDtimeout;	/* assign */
	+ 
	  	c = r->unit->dev->ctlr;
	  
	  	check = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1702,1708 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1816,1822
	  
	  	setmovedata(&d->msg_out_buf, DMASEG(d->msg_out), bc);
	  	setmovedata(&d->cmd_buf, DMASEG(r->cmd), r->clen);
	- 	calcblockdma(d, DMASEG(r->data), r->dlen);
	+ 	calcblockdma(d, r->data ? DMASEG(r->data) : 0, r->dlen);
	  
	  	if (DEBUG(0)) {
	  		KPRINT(PRINTPREFIX "%d/%d: exec: ", target, r->lun);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1722,1735 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1836,1850
	  
	  	d->p9status = SDnostatus;
	  	d->parityerror = 0;
	- 
	+ 	coherence();
	  	d->stateb = A_STATE_ISSUE;		/* start operation */
	+ 	coherence();
	  
	  	ilock(c);
	  	if (c->ssm)
	- 		c->n->dcntl |= 0x10;		/* SSI */
	+ 		c->n->dcntl |= 0x10;		/* single step */
	  	if (c->running) {
	- 		c->n->istat |= Sigp;
	+ 		c->n->istat = Sigp;
	  	}
	  	else {
	  		start(c, E_issue_check);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1802,1807 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1917,1923
	  		 * so the Dsa can be re-used.
	  		 */
	  		lesetl(&d->stateb, A_STATE_ALLOCATED);
	+ 		coherence();
	  		goto docheck;
	  	}
	  	qunlock(&c->q[target]);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1825,1836 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1941,1954
	  	return r->status = status;
	  }
	  
	+ #define	vpt ((ulong*)VPT)
	+ #define	VPTX(va)		(((ulong)(va))>>12)
	  static void
	  cribbios(Controller *c)
	  {
	  	c->bios.scntl3 = c->n->scntl3;
	  	c->bios.stest2 = c->n->stest2;
	- 	KPRINT(PRINTPREFIX "bios scntl3(%.2x) stest2(%.2x)\n", c->bios.scntl3, c->bios.stest2);
	+ 	print(PRINTPREFIX "bios scntl3(%.2x) stest2(%.2x)\n", c->bios.scntl3, c->bios.stest2);
	  }
	  
	  static int
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1879,1886 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:1997,2002
	  { SYM_1011_DID,   0xff, "SYM53C1010",	Burst128, 16, 64, Prefetch|LocalRAM|BigFifo|Wide|Ultra|Ultra2 },
	  };
	  
	- #define offsetof(s, t) ((ulong)&((s *)0)->t)
	- 
	  static int
	  xfunc(Controller *c, enum na_external x, unsigned long *v)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1968,1973 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:2084,2090
	  	Controller *ctlr;
	  	SDev *sdev, *head, *tail;
	  	ulong regpa, *script, scriptpa;
	+ 	void *regva, *scriptva;
	  
	  	if(cp = getconf("*maxsd53c8xx"))
	  		nctlr = strtoul(cp, 0, 0);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:1995,2017 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:2112,2138
	  				continue;
	  			ba++;
	  		}
	- 		regpa = upamalloc(regpa & ~0x0F, p->mem[1].size, 0);
	  		if(regpa == 0)
	+ 			print("regpa 0\n");
	+ 		regpa &= ~0xF;
	+ 		regva = vmap(regpa, p->mem[1].size);
	+ 		if(regva == 0)
	  			continue;
	  
	  		script = nil;
	  		scriptpa = 0;
	+ 		scriptva = nil;
	  		scriptma = nil;
	  		if((v->feature & LocalRAM) && sizeof(na_script) <= 4096){
	  			scriptpa = p->mem[ba].bar;
	  			if((scriptpa & 0x04) && p->mem[ba+1].bar){
	- 				upafree(regpa, p->mem[1].size);
	+ 				vunmap(regva, p->mem[1].size);
	  				continue;
	  			}
	- 			scriptpa = upamalloc(scriptpa & ~0x0F,
	- 					p->mem[ba].size, 0);
	- 			if(scriptpa)
	- 				script = KADDR(scriptpa);
	+ 			scriptpa &= ~0x0F;
	+ 			scriptva = vmap(scriptpa, p->mem[ba].size);
	+ 			if(scriptva)
	+ 				script = scriptva;
	  		}
	  		if(scriptpa == 0){
	  			/*
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:2020,2026 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:2141,2147
	  			 */
	  			scriptma = malloc(sizeof(na_script));
	  			if(scriptma == nil){
	- 				upafree(regpa, p->mem[1].size);
	+ 				vunmap(regva, p->mem[1].size);
	  				continue;
	  			}
	  			scriptpa = DMASEG(scriptma);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:2037,2049 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:2158,2180
	  				free(sdev);
	  			if(scriptma)
	  				free(scriptma);
	- 			else
	- 				upafree(scriptpa, p->mem[ba].size);
	- 			upafree(regpa, p->mem[1].size);
	+ 			else if(scriptva)
	+ 				vunmap(scriptva, p->mem[ba].size);
	+ 			if(regva)
	+ 				vunmap(regva, p->mem[1].size);
	  			continue;
	  		}
	  
	- 		ctlr->n = KADDR(regpa);
	+ 		if(dsaend == nil)
	+ 			dsaend = xalloc(sizeof *dsaend);
	+ 		lesetl(&dsaend->stateb, A_STATE_END);
	+ 	//	lesetl(dsaend->next, DMASEG(dsaend));
	+ 		coherence();
	+ 		lesetl(ctlr->dsalist.head, DMASEG(dsaend));
	+ 		coherence();
	+ 		ctlr->dsalist.freechain = 0;
	+ 
	+ 		ctlr->n = regva;
	  		ctlr->v = v;
	  		ctlr->script = script;
	  		memmove(ctlr->script, na_script, sizeof(na_script));
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:2062,2080 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:2193,2209
	  		}
	  		swabl(ctlr->script, ctlr->script, sizeof(na_script));
	  
	- 		ctlr->dsalist.freechain = 0;
	- 		lesetl(ctlr->dsalist.head, 0);
	- 
	  		ctlr->pcidev = p;
	  
	  		sdev->ifc = &sd53c8xxifc;
	  		sdev->ctlr = ctlr;
	+ 		sdev->idno = '0';
	  		if(!(v->feature & Wide))
	  			sdev->nunit = 8;
	  		else
	  			sdev->nunit = MAXTARGET;
	  		ctlr->sdev = sdev;
	- 
	+ 		
	  		if(head != nil)
	  			tail->next = sdev;
	  		else
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:2087,2098 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:2216,2221
	  	return head;
	  }
	  
	- static SDev*
	- sd53c8xxid(SDev* sdev)
	- {
	- 	return scsiid(sdev, &sd53c8xxifc);
	- }
	- 
	  static int
	  sd53c8xxenable(SDev* sdev)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:2104,2116 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:2227,2239
	  	pcidev = ctlr->pcidev;
	  
	  	pcisetbme(pcidev);
	- 	snprint(name, sizeof(name), "%s (%s)", sdev->name, sdev->ifc->name);
	- 	intrenable(pcidev->intl, sd53c8xxinterrupt, ctlr, pcidev->tbdf, name);
	  
	  	ilock(ctlr);
	  	synctabinit(ctlr);
	  	cribbios(ctlr);
	  	reset(ctlr);
	+ 	snprint(name, sizeof(name), "%s (%s)", sdev->name, sdev->ifc->name);
	+ 	intrenable(pcidev->intl, sd53c8xxinterrupt, ctlr, pcidev->tbdf, name);
	  	iunlock(ctlr);
	  
	  	return 1;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.c:2121,2127 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.c:2244,2249
	  
	  	sd53c8xxpnp,			/* pnp */
	  	nil,				/* legacy */
	- 	sd53c8xxid,			/* id */
	  	sd53c8xxenable,			/* enable */
	  	nil,				/* disable */
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 12657 Nov  6 10:22 sys/src/9/pc/sd53c8xx.n
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:54,59 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:54,60
	  SIR_NOTIFY_WSR = 115
	  SIR_NOTIFY_LOAD_SYNC = 116
	  SIR_NOTIFY_RESELECTED_ON_SELECT = 117
	+ SIR_NOTIFY_LOAD_STATE = 118
	  
	  STATE_FREE = 0
	  STATE_ALLOCATED = 1
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:60,65 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:61,67
	  STATE_ISSUE = 2
	  STATE_DISCONNECTED = 3
	  STATE_DONE = 4
	+ STATE_END = 5
	  
	  RESULT_OK = 0
	  	
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:76,82 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:78,84
	  BSIZE = 512
	  //BSIZE=4096
	  
	- idle:
	+  // idle:
	  	jump	wait_for_reselection	
	  start:
	  	call	load_sync
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:84,90 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:86,92
	  //	int	SIR_NOTIFY_ISSUE
	  	clear	target
	  	select	atn from scsi_id_buf, reselected_on_select // do I need to clear ATN here?
	- 	jump	start1, when msg_in
	+ 	jump	start1, when msg_in	// why is this here?
	  start1:
	  //	move	14 to ctest0
	  	move	from msg_out_buf, when msg_out
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:320,334 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:322,327
	   	move	memory 4, dsa_head, dsa
	  find_dsa_loop:
	  //	move	7 to ctest0
	- 	move	dsa0 to sfbr
	- 	jump	find_dsa_1, if not 0
	- 	move	dsa1 to sfbr
	- 	jump	find_dsa_1, if not 0
	- 	move	dsa2 to sfbr
	- 	jump	find_dsa_1, if not 0
	- 	move	dsa3 to sfbr
	- 	int	error_reselected, if 0			// couldn't match dsa (panic)
	- find_dsa_1:
	  //	move	8 to ctest0
	  	// load state from DSA into dsa_copy
	  	call	load_state
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:335,340 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:328,334
	  	move	memory 4, state, scratcha		// get dsastate in scratcha
	  	move	scratcha0 to sfbr			// and state variable in sfbr
	  	jump	find_dsa_next, if not STATE_DISCONNECTED // wrong state
	+ 	int	error_reselected, if STATE_END
	  	move	ssid & ssid_mask to sfbr			// get target ID
	  	move	memory 1, targ, find_dsa_smc1		// forge target comparison instruction
	  find_dsa_smc1:
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:350,355 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:344,350
	  // id_out terminated early
	  // most likely the message wasn't recognised
	  // clear ATN and accept the message in
	+ // called from sd53c8xx.c directly
	  id_out_mismatch_recover:
	  	clear	atn
	          jump    msg_in_phase, when msg_in
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:374,379 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:369,375
	  	jump	status_phase, if status
	  	jump	msg_in_phase, if msg_in
	  	int	error_unexpected_phase
	+ 
	  post_data_to_decisions:
	  	jump	status_phase, when status
	  	jump	msg_in_phase, if msg_in
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:398,403 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:394,423
	  dsa_save_len = dsa_save_end - dsa_copy
	  
	  load_state:
	+ //	int	SIR_NOTIFY_LOAD_STATE
	+ 	jump load_state_okay
	+ 
	+ 	move	dsa0 to sfbr
	+ 	jump load_state_okay, if not 0
	+ 	move	dsa1 to sfbr
	+ 	jump load_state_okay, if not 0
	+ 	move	dsa2 to sfbr
	+ 	jump load_state_okay, if not 0
	+ 	move	dsa3 to sfbr
	+ 	jump load_state_okay, if not 0
	+ 	// dsa is 0
	+ 	move	memory 4, dsa, dmaaddr
	+ 	move	memory 4, dsa, targ
	+ 	move	memory 4, dsa, lun
	+ 	move	memory 4, dsa, sync
	+ 	move	memory 4, dsa, next
	+ 	move	memory 4, dsa, scratcha
	+ 	move	STATE_END to sfbr
	+ 	move	sfbr to scratcha0
	+ 	move	memory 4, scratcha, state
	+ 	return
	+ 
	+ load_state_okay:
	  	// load state from DSA into dsa_copy
	  //	move	9 to ctest0
	  	move	memory 4, dsa, load_state_smc0 + 4
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:419,443 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:439,454
	  //	move	1 to ctest0
	  	move	memory 4, dsa_head, dsa
	  issue_check_loop:
	- //	move	2 to ctest0
	- 	move	dsa0 to sfbr
	- 	jump	issue_check_1, if not 0
	- 	move	dsa1 to sfbr
	- 	jump	issue_check_1, if not 0
	- 	move	dsa2 to sfbr
	- 	jump	issue_check_1, if not 0
	- 	move	dsa3 to sfbr
	- 	jump	wait_for_reselection, if 0		// nothing to do
	- issue_check_1:
	- //	move	3 to ctest0
	   	call	load_state
	  	move	memory 4, state, scratcha		// get dsastate in scratcha
	  	move	scratcha0 to sfbr			// and state variable in sfbr
	  	jump	start, if STATE_ISSUE			// right state
	- issue_check_next:
	- //	move	4 to ctest0
	+ 	jump	wait_for_reselection, if STATE_END
	+  //	move	4 to ctest0
	  	move	memory 4, next, dsa			// find next
	  	jump	issue_check_loop
	+ 
	+ 
	  load_sync:
	  	move	memory 4, sync, scratcha		// load the sync stuff
	  	move	scratcha0 to sfbr			// assuming load_state has been called
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sd53c8xx.n:444,448 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sd53c8xx.n:455,459
	  	move	sfbr to scntl3
	  	move	scratcha1 to sfbr
	  	move	sfbr to sxfer
	- //	int	SIR_NOTIFY_LOAD_SYNC
	+  //	int	SIR_NOTIFY_LOAD_SYNC
	  	return
 [rsc] --rw-rw-r-- M 451989 glenda sys 52168 Nov  6 10:22 sys/src/9/pc/sdata.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:9,14 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:9,17
	  
	  #include "../port/sd.h"
	  
	+ #define	HOWMANY(x, y)	(((x)+((y)-1))/(y))
	+ #define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))
	+ 
	  extern SDifc sdataifc;
	  
	  enum {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:254,267 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:257,271
	  typedef struct Ctlr Ctlr;
	  typedef struct Drive Drive;
	  
	- typedef struct Prd {
	+ typedef struct Prd {			/* Physical Region Descriptor */
	  	ulong	pa;			/* Physical Base Address */
	  	int	count;
	  } Prd;
	  
	  enum {
	- 	PRDmaxio	= 32*1024,	/* must be power of 2 <= 64*1024 */
	- 	Nprd		= SDmaxio/PRDmaxio+2,
	+ 	BMspan		= 64*1024,	/* must be power of 2 <= 64*1024 */
	+ 
	+ 	Nprd		= SDmaxio/BMspan+2,
	  };
	  
	  typedef struct Ctlr {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:270,275 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:274,281
	  	int	irq;
	  	int	tbdf;
	  	int	bmiba;			/* bus master interface base address */
	+ 	int	maxio;			/* sector count transfer maximum */
	+ 	int	span;			/* don't span this boundary with dma */
	  
	  	Pcidev*	pcidev;
	  	void	(*ienable)(Ctlr*);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:734,740 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:740,747
	  	SDev *sdev;
	  	Drive *drive;
	  	int dev, error, rhi, rlo;
	- 
	+ 	static int nonlegacy = 'C';
	+ 	
	  	if(ioalloc(cmdport, 8, 0, "atacmd") < 0) {
	  		print("ataprobe: Cannot allocate %X\n", cmdport);
	  		return nil;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:877,883 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:884,903
	  	ctlr->irq = irq;
	  	ctlr->tbdf = BUSUNKNOWN;
	  	ctlr->command = Cedd;		/* debugging */
	- 
	+ 	
	+ 	switch(cmdport){
	+ 	default:
	+ 		sdev->idno = nonlegacy;
	+ 		break;
	+ 	case 0x1F0:
	+ 		sdev->idno = 'C';
	+ 		nonlegacy = 'E';
	+ 		break;
	+ 	case 0x170:
	+ 		sdev->idno = 'D';
	+ 		nonlegacy = 'E';
	+ 		break;
	+ 	}
	  	sdev->ifc = &sdataifc;
	  	sdev->ctlr = ctlr;
	  	sdev->nunit = 2;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:921,932 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:941,966
	  static SDev*
	  ataprobew(DevConf *cf)
	  {
	+ 	char *p;
	+ 	ISAConf isa;
	+ 	
	  	if (cf->nports != 2)
	  		error(Ebadarg);
	  
	+ 	memset(&isa, 0, sizeof isa);
	+ 	isa.port = cf->ports[0].port;
	+ 	isa.irq = cf->intnum;
	+ 	if((p=strchr(cf->type, '/')) == nil || pcmspecial(p+1, &isa) < 0)
	+ 		error("cannot find controller");
	+ 
	  	return ataprobe(cf->ports[0].port, cf->ports[1].port, cf->intnum);
	  }
	  
	+ /*
	+  * These are duplicated with sdsetsense, etc., in devsd.c, but
	+  * those assume that the disk is not SCSI while in fact here
	+  * ata drives are not SCSI but ATAPI ones kind of are.
	+  */
	  static int
	  atasetsense(Drive* drive, int status, int key, int asc, int ascq)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:938,943 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:972,1004
	  }
	  
	  static int
	+ atamodesense(Drive* drive, uchar* cmd)
	+ {
	+ 	int len;
	+ 
	+ 	/*
	+ 	 * Fake a vendor-specific request with page code 0,
	+ 	 * return the drive info.
	+ 	 */
	+ 	if((cmd[2] & 0x3F) != 0 && (cmd[2] & 0x3F) != 0x3F)
	+ 		return atasetsense(drive, SDcheck, 0x05, 0x24, 0);
	+ 	len = (cmd[7]<<8)|cmd[8];
	+ 	if(len == 0)
	+ 		return SDok;
	+ 	if(len < 8+sizeof(drive->info))
	+ 		return atasetsense(drive, SDcheck, 0x05, 0x1A, 0);
	+ 	if(drive->data == nil || drive->dlen < len)
	+ 		return atasetsense(drive, SDcheck, 0x05, 0x20, 1);
	+ 	memset(drive->data, 0, 8);
	+ 	drive->data[0] = sizeof(drive->info)>>8;
	+ 	drive->data[1] = sizeof(drive->info);
	+ 	memmove(drive->data+8, drive->info, sizeof(drive->info));
	+ 	drive->data += 8+sizeof(drive->info);
	+ 
	+ 	return SDok;
	+ }
	+ 
	+ static int
	  atastandby(Drive* drive, int period)
	  {
	  	Ctlr* ctlr;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:959,965 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1020,1026
	  
	  	while(waserror())
	  		;
	- 	tsleep(ctlr, atadone, ctlr, 30*1000);
	+ 	tsleep(ctlr, atadone, ctlr, 60*1000);
	  	poperror();
	  
	  	done = ctlr->done;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:970,1002 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1031,1036
	  	return SDok;
	  }
	  
	- static int
	- atamodesense(Drive* drive, uchar* cmd)
	- {
	- 	int len;
	- 
	- 	/*
	- 	 * Fake a vendor-specific request with page code 0,
	- 	 * return the drive info.
	- 	 */
	- 	if((cmd[2] & 0x3F) != 0 && (cmd[2] & 0x3F) != 0x3F)
	- 		return atasetsense(drive, SDcheck, 0x05, 0x24, 0);
	- 	len = (cmd[7]<<8)|cmd[8];
	- 	if(len == 0)
	- 		return SDok;
	- 	if(len < 8+sizeof(drive->info))
	- 		return atasetsense(drive, SDcheck, 0x05, 0x1A, 0);
	- 	if(drive->data == nil || drive->dlen < len)
	- 		return atasetsense(drive, SDcheck, 0x05, 0x20, 1);
	- 	memset(drive->data, 0, 8);
	- 	drive->data[0] = sizeof(drive->info)>>8;
	- 	drive->data[1] = sizeof(drive->info);
	- 	memmove(drive->data+8, drive->info, sizeof(drive->info));
	- 	drive->data += 8+sizeof(drive->info);
	- 
	- 	return SDok;
	- }
	- 
	  static void
	  atanop(Drive* drive, int subcommand)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1055,1072 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1089,1106
	  	Prd *prd;
	  	ulong pa;
	  	Ctlr *ctlr;
	- 	int bmiba, bmisx, count;
	+ 	int bmiba, bmisx, count, i, span;
	  
	+ 	ctlr = drive->ctlr;
	  	pa = PCIWADDR(drive->data);
	  	if(pa & 0x03)
	  		return -1;
	- 	ctlr = drive->ctlr;
	- 	prd = ctlr->prdt;
	  
	  	/*
	  	 * Sometimes drives identify themselves as being DMA capable
	  	 * although they are not on a busmastering controller.
	  	 */
	+ 	prd = ctlr->prdt;
	  	if(prd == nil){
	  		drive->dmactl = 0;
	  		print("disabling dma: not on a busmastering controller\n");
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1073,1083 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1107,1120
	  		return -1;
	  	}
	  
	- 	for(;;){
	+ 	for(i = 0; len && i < Nprd; i++){
	  		prd->pa = pa;
	- 		count = PRDmaxio - (pa & (PRDmaxio-1));
	+ 		span = ROUNDUP(pa, ctlr->span);
	+ 		if(span == pa)
	+ 			span += ctlr->span;
	+ 		count = span - pa;
	  		if(count >= len){
	- 			prd->count = PrdEOT|(len & (PRDmaxio-1));
	+ 			prd->count = PrdEOT|len;
	  			break;
	  		}
	  		prd->count = count;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1085,1090 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1122,1129
	  		pa += count;
	  		prd++;
	  	}
	+ 	if(i == Nprd)
	+ 		(prd-1)->count |= PrdEOT;
	  
	  	bmiba = ctlr->bmiba;
	  	outl(bmiba+Bmidtpx, PCIWADDR(ctlr->prdt));
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1271,1277 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1310,1316
	  			break;
	  		ilock(ctlr);
	  		atadmainterrupt(drive, 0);
	- 		if(!drive->error && timeo > 10){
	+ 		if(!drive->error && timeo > 20){
	  			ataabort(drive, 0);
	  			atadmastop(ctlr);
	  			drive->dmactl = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1389,1395 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1428,1435
	  	case Cws:
	  	case Cwsm:
	  		microdelay(1);
	- 		as = ataready(cmdport, ctlport, 0, Bsy, Drq|Err, 1000);
	+ 		/* 10*1000 for flash ide drives - maybe detect them? */
	+ 		as = ataready(cmdport, ctlport, 0, Bsy, Drq|Err, 10*1000);
	  		if(as < 0 || (as & Err)){
	  			iunlock(ctlr);
	  			return -1;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1430,1437 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1470,1477
	  {
	  	uchar *p;
	  	Ctlr *ctlr;
	- 	int count, max;
	  	vlong lba, len;
	+ 	int count, maxio;
	  
	  	/*
	  	 * Map SCSI commands into ATA commands for discs.
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1522,1528 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1562,1568
	  		*p++ = len>>16;
	  		*p++ = len>>8;
	  		*p = len;
	- 		drive->data += 8;
	+ 		drive->data += 12;
	  		return SDok;
	  
	  	case 0x28:			/* read */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1541,1550 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1581,1595
	  	if(drive->dlen < count*drive->secsize)
	  		count = drive->dlen/drive->secsize;
	  	qlock(ctlr);
	+ 	if(ctlr->maxio)
	+ 		maxio = ctlr->maxio;
	+ 	else if(drive->flags & Lba48)
	+ 		maxio = 65536;
	+ 	else
	+ 		maxio = 256;
	  	while(count){
	- 		max = (drive->flags&Lba48) ? 65536 : 256;
	- 		if(count > max)
	- 			drive->count = max;
	+ 		if(count > maxio)
	+ 			drive->count = maxio;
	  		else
	  			drive->count = count;
	  		if(atageniostart(drive, lba)){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1557,1563 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1602,1608
	  
	  		while(waserror())
	  			;
	- 		tsleep(ctlr, atadone, ctlr, 30*1000);
	+ 		tsleep(ctlr, atadone, ctlr, 60*1000);
	  		poperror();
	  		if(!ctlr->done){
	  			/*
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1797,1804 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1842,1849
	  {
	  	Ctlr *ctlr;
	  	Pcidev *p;
	- 	int channel, ispc87415, pi, r;
	  	SDev *legacy[2], *sdev, *head, *tail;
	+ 	int channel, ispc87415, maxio, pi, r, span;
	  
	  	legacy[0] = legacy[1] = head = tail = nil;
	  	if(sdev = ataprobe(0x1F0, 0x3F4, IrqATA0)){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1839,1844 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1884,1891
	  			continue;
	  		pi = p->ccrp;
	  		ispc87415 = 0;
	+ 		maxio = 0;
	+ 		span = BMspan;
	  
	  		switch((p->did<<16)|p->vid){
	  		default:
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1868,1875 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1915,1925
	  		case (0x4D69<<16)|0x105A:	/* Promise Ultra/133 TX2 */
	  		case (0x3373<<16)|0x105A:	/* Promise 20378 RAID */
	  		case (0x3149<<16)|0x1106:	/* VIA VT8237 SATA/RAID */
	- 		case (0x3112<<16)|0x1095:   	/* SiL 3112 SATA (DMA busted?) */
	- 		case (0x3114<<16)|0x1095:	/* SiL 3114 SATA/RAID */
	+ 		case (0x3112<<16)|0x1095:   	/* SiI 3112 SATA/RAID */
	+ 			maxio = 15;
	+ 			span = 8*1024;
	+ 			/*FALLTHROUGH*/
	+ 		case (0x3114<<16)|0x1095:	/* SiI 3114 SATA/RAID */
	  			pi = 0x85;
	  			break;
	  		case (0x0004<<16)|0x1103:	/* HighPoint HPT366 */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1932,1937 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:1982,1988
	  				r &= ~0x2000;
	  				pcicfgw32(sb, 0x64, r);
	  			}
	+ 			span = 32*1024;
	  			break;
	  		case (0x5513<<16)|0x1039:	/* SiS 962 */
	  		case (0x0646<<16)|0x1095:	/* CMD 646 */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:1979,1984 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:2030,2037
	  				ctlr = sdev->ctlr;
	  
	  			ctlr->pcidev = p;
	+ 			ctlr->maxio = maxio;
	+ 			ctlr->span = span;
	  			if(!(pi & 0x80))
	  				continue;
	  			ctlr->bmiba = (p->mem[4].bar & ~0x01) + channel*8;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:2030,2075 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:2083,2088
	  	return ataprobe(port, port+0x204, irq);
	  }
	  
	- static SDev*
	- ataid(SDev* sdev)
	- {
	- 	int i;
	- 	Ctlr *ctlr;
	- 	char name[32];
	- 
	- 	/*
	- 	 * Legacy controllers are always 'C' and 'D' and if
	- 	 * they exist and have drives will be first in the list.
	- 	 * If there are no active legacy controllers, native
	- 	 * controllers start at 'C'.
	- 	 */
	- 	if(sdev == nil)
	- 		return nil;
	- 	ctlr = sdev->ctlr;
	- 	if(ctlr->cmdport == 0x1F0 || ctlr->cmdport == 0x170)
	- 		i = 2;
	- 	else
	- 		i = 0;
	- 	while(sdev){
	- 		if(sdev->ifc == &sdataifc){
	- 			ctlr = sdev->ctlr;
	- 			if(ctlr->cmdport == 0x1F0)
	- 				sdev->idno = 'C';
	- 			else if(ctlr->cmdport == 0x170)
	- 				sdev->idno = 'D';
	- 			else{
	- 				sdev->idno = 'C'+i;
	- 				i++;
	- 			}
	- 			snprint(name, sizeof(name), "sd%c", sdev->idno);
	- 			kstrdup(&sdev->name, name);
	- 		}
	- 		sdev = sdev->next;
	- 	}
	- 
	- 	return nil;
	- }
	- 
	  static int
	  ataenable(SDev* sdev)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdata.c:2230,2236 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdata.c:2243,2248
	  
	  	atapnp,				/* pnp */
	  	atalegacy,			/* legacy */
	- 	ataid,				/* id */
	  	ataenable,			/* enable */
	  	atadisable,			/* disable */
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 27737 Nov  6 10:23 sys/src/9/pc/sdmylex.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdmylex.c:1012,1017 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdmylex.c:1012,1018
	  		goto buggery;
	  	sdev->ifc = &sdmylexifc;
	  	sdev->ctlr = ctlr;
	+ 	sdev->idno = '0';
	  	ctlr->sdev = sdev;
	  	if(!ctlr->wide)
	  		sdev->nunit = 8;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdmylex.c:1089,1100 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdmylex.c:1090,1095
	  	return head;
	  }
	  
	- static SDev*
	- mylexid(SDev* sdev)
	- {
	- 	return scsiid(sdev, &sdmylexifc);
	- }
	- 
	  static int
	  mylex24enable(Ctlr* ctlr)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdmylex.c:1232,1238 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdmylex.c:1227,1232
	  
	  	mylexpnp,			/* pnp */
	  	nil,				/* legacy */
	- 	mylexid,			/* id */
	  	mylexenable,			/* enable */
	  	nil,				/* disable */
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 21180 Nov  6 14:44 sys/src/9/pc/trap.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:9,14 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:9,16
	  #include	"../port/error.h"
	  #include	<trace.h>
	  
	+ static int trapinited;
	+ 
	  void	noted(Ureg*, ulong);
	  
	  static void debugbpt(Ureg*, void*);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:175,182 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:177,189
	  	outb(0x61, x);
	  }
	  
	+ /*
	+  * Minimal trap setup.  Just enough so that we can panic
	+  * on traps (bugs) during kernel initialization.  
	+  * Called very early - malloc is not yet available.
	+  */
	  void
	- trapinit(void)
	+ trapinit0(void)
	  {
	  	int d1, v;
	  	ulong vaddr;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:204,210 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:211,221
	  		idt[v].d1 = d1;
	  		vaddr += 6;
	  	}
	+ }
	  
	+ void
	+ trapinit(void)
	+ {
	  	/*
	  	 * Special traps.
	  	 * Syscall() is called directly without going through trap().
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:216,221 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:227,233
	  	nmienable();
	  
	  	addarchfile("irqalloc", 0444, irqallocread, nil);
	+ 	trapinited = 1;
	  }
	  
	  static char* excname[32] = {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:306,311 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:318,330
	  	Vctl *ctl, *v;
	  	Mach *mach;
	  
	+ 	if(!trapinited){
	+ 		/* fault386 can give a better error message */
	+ 		if(ureg->trap == VectorPF)
	+ 			fault386(ureg, nil);
	+ 		panic("trap %lud: not ready", ureg->trap);
	+ 	}
	+ 
	  	m->perf.intrts = perfticks();
	  	user = (ureg->cs & 0xFFFF) == UESEL;
	  	if(user){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:507,513 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:526,532
	  	iprint("dumpstack\n");
	  
	  	x = 0;
	- 	x += print("ktrace /kernel/path %.8lux %.8lux\n", ureg->pc, ureg->sp);
	+ 	x += print("ktrace /kernel/path %.8lux %.8lux <<EOF\n", ureg->pc, ureg->sp);
	  	i = 0;
	  	if(up
	  	&& (ulong)&l >= (ulong)up->kstack
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:522,528 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:541,547
	  
	  	for(l=(ulong)&l; l<estack; l+=4){
	  		v = *(ulong*)l;
	- 		if((KTZERO < v && v < (ulong)&etext) || estack-l<256){
	+ 		if((KTZERO < v && v < (ulong)&etext) || estack-l<32){
	  			/*
	  			 * we could Pick off general CALL (((uchar*)v)[-5] == 0xE8)
	  			 * and CALL indirect through AX (((uchar*)v)[-2] == 0xFF && ((uchar*)v)[-2] == 0xD0),
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:538,543 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:557,563
	  	}
	  	if(i)
	  		print("\n");
	+ 	print("EOF\n");
	  }
	  
	  void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:571,578 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:591,596
	  	print("unexpected trap %lud; ignoring\n", ureg->trap);
	  }
	  
	- extern void checkpages(void);
	- 
	  static void
	  fault386(Ureg* ureg, void*)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:581,592 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:599,618
	  	char buf[ERRMAX];
	  
	  	addr = getcr2();
	- 	user = (ureg->cs & 0xFFFF) == UESEL;
	- 	if(!user && mmukmapsync(addr))
	- 		return;
	  	read = !(ureg->ecode & 2);
	+ 
	+ 	user = (ureg->cs & 0xFFFF) == UESEL;
	+ 	if(!user){
	+ 		if(vmapsync(addr))
	+ 			return;
	+ 		if(addr >= USTKTOP)
	+ 			panic("kernel fault: bad address pc=0x%.8lux addr=0x%.8lux", ureg->pc, addr);
	+ 		if(up == nil)
	+ 			panic("kernel fault: no user process pc=0x%.8lux addr=0x%.8lux", ureg->pc, addr);
	+ 	}
	  	if(up == nil)
	- 		panic("fault but up is zero; pc 0x%8.8lux addr 0x%8.8lux\n", ureg->pc, addr);
	+ 		panic("user fault: up=0 pc=0x%.8lux addr=0x%.8lux", ureg->pc, addr);
	+ 
	  	insyscall = up->insyscall;
	  	up->insyscall = 1;
	  	n = fault(addr, read);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:597,603 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:623,629
	  		}
	  		checkpages();
	  		sprint(buf, "sys: trap: fault %s addr=0x%lux",
	- 			read? "read" : "write", addr);
	+ 			read ? "read" : "write", addr);
	  		postnote(up, 1, buf, NDebug);
	  	}
	  	up->insyscall = insyscall;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/trap.c:887,892 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/trap.c:913,921
	  {
	  	ulong *sp;
	  	Ureg *ureg;
	+ 
	+ 	up->fpstate = FPinit;
	+ 	fpoff();
	  
	  	sp = (ulong*)(USTKTOP - ssize);
	  	*--sp = nargs;
 [rsc] --rw-rw-r-- M 451989 glenda sys 4030 Nov  6 10:23 sys/src/9/pc/vgai81x.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgai81x.c:49,142 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgai81x.c:49,92
	  	return nil;
	  }
	  
	- static ulong
	- i81xlinear(VGAscr* scr, int* size, int* align)
	- {
	- 	Pcidev *p;
	- 	int oapsize, wasupamem;
	- 	ulong aperture, oaperture, fbuf, fbend, *rp;
	- 
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	aperture = 0;
	- 	p = i81xpcimatch();
	- 	if(p != nil) {
	- 		aperture = p->mem[0].bar & ~0x0F;
	- 		*size = p->mem[0].size;
	- 		if(*size > Fbsize)
	- 			*size = Fbsize;
	- 	}
	- 
	- 	if(wasupamem){
	- 		if(oaperture == aperture)
	- 			return oaperture;
	- 		upafree(oaperture, oapsize);
	- 	}
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0)){
	- 			aperture = oaperture;
	- 			scr->isupamem = 1;
	- 		}
	- 		else
	- 			scr->isupamem = 0;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	/* allocate space for frame buffer, populate page table */
	- 	if(oapsize == 0) {
	- 		fbuf = PADDR(xspanalloc(*size, BY2PG, 0));
	- 		fbend = PGROUND(fbuf+*size);
	- 		rp = KADDR(scr->io+0x10000);
	- 		while(fbuf < fbend) {
	- 			*rp++ = fbuf | (1<<0);
	- 			fbuf += BY2PG;
	- 		}
	- 	}
	- 	return aperture;
	- }
	- 
	  static void
	  i81xenable(VGAscr* scr)
	  {
	  	Pcidev *p;
	- 	int align, size;
	+ 	int size;
	  	Mach *mach0;
	- 	ulong aperture, pgtbl, *rp, cursor, *pte;
	- 
	- 	/*
	- 	 * Only once, can't be disabled for now.
	- 	 * scr->io holds the physical address of
	- 	 * the MMIO registers.
	- 	 */
	- 	if(scr->io)
	+ 	ulong *pgtbl, *rp, cursor, *pte, fbuf, fbend;
	+ 	
	+ 	if(scr->mmio)
	  		return;
	  	p = i81xpcimatch();
	  	if(p == nil)
	  		return;
	- 	scr->io = upamalloc(p->mem[1].bar & ~0x0F, p->mem[1].size, 0);
	- 	if(scr->io == 0)
	+ 	scr->mmio = vmap(p->mem[1].bar & ~0x0F, p->mem[1].size);
	+ 	if(scr->mmio == 0)
	  		return;
	+ 	addvgaseg("i81xmmio", p->mem[1].bar&~0x0F, p->mem[1].size);
	  
	  	/* allocate page table */
	- 	pgtbl = PADDR(xspanalloc(64*1024, BY2PG, 0));
	- 	rp = KADDR(scr->io+0x2020);
	- 	*rp = pgtbl | 1;
	+ 	pgtbl = xspanalloc(64*1024, BY2PG, 0);
	+ 	scr->mmio[0x2020/4] = PADDR(pgtbl) | 1;
	  
	- 	addvgaseg("i81xmmio", (ulong)scr->io, p->mem[0].size);
	- 
	  	size = p->mem[0].size;
	- 	align = 0;
	- 	aperture = i81xlinear(scr, &size, &align);
	- 	if(aperture){
	- 		scr->aperture = aperture;
	- 		scr->apsize = size;
	- 		addvgaseg("i81xscreen", aperture, size);
	+ 	if(size > 0)
	+ 		size = Fbsize;
	+ 	vgalinearaddr(scr, p->mem[0].bar&~0xF, size);
	+ 	addvgaseg("i81xscreen", p->mem[0].bar&~0xF, size);
	+ 
	+ 	/*
	+ 	 * allocate backing store for frame buffer
	+ 	 * and populate device page tables.
	+ 	 */
	+ 	fbuf = PADDR(xspanalloc(size, BY2PG, 0));
	+ 	fbend = PGROUND(fbuf+size);
	+ 	rp = scr->mmio+0x10000/4;
	+ 	while(fbuf < fbend) {
	+ 		*rp++ = fbuf | 1;
	+ 		fbuf += BY2PG;
	  	}
	  
	  	/*
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgai81x.c:147,155 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgai81x.c:97,105
	  	mach0 = MACHP(0);
	  	pte = mmuwalk(mach0->pdb, cursor, 2, 0);
	  	if(pte == nil)
	- 		panic("i81x cursor");
	+ 		panic("i81x cursor mmuwalk");
	  	*pte |= PTEUNCACHED;
	- 	scr->storage = PADDR(cursor);
	+ 	scr->storage = cursor;
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgai81x.c:157,165 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgai81x.c:107,115
	  {
	  	CursorI81x *hwcurs;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	hwcurs = KADDR(scr->io+hwCur);
	+ 	hwcurs = (void*)((uchar*)scr->mmio+hwCur);
	  	hwcurs->ctl = (1<<4);
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgai81x.c:170,178 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgai81x.c:120,128
	  	uchar *p;
	  	CursorI81x *hwcurs;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	hwcurs = KADDR(scr->io+hwCur);
	+ 	hwcurs = (void*)((uchar*)scr->mmio+hwCur);
	  
	  	/*
	  	 * Disable the cursor then load the new image in
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgai81x.c:181,187 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgai81x.c:131,137
	  	 * transparent.
	  	 */
	  	hwcurs->ctl = (1<<4);
	- 	p = KADDR(scr->storage);
	+ 	p = (uchar*)scr->storage;
	  	for(y = 0; y < 16; y += 2) {
	  		*p++ = ~(curs->clr[2*y]|curs->set[2*y]);
	  		*p++ = ~(curs->clr[2*y+1]|curs->set[2*y+1]);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgai81x.c:213,221 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgai81x.c:163,171
	  	ulong pos;
	  	CursorI81x *hwcurs;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return 1;
	- 	hwcurs = KADDR(scr->io+hwCur);
	+ 	hwcurs = (void*)((uchar*)scr->mmio+hwCur);
	  
	  	x = p.x+scr->offset.x;
	  	y = p.y+scr->offset.y;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgai81x.c:242,256 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgai81x.c:192,206
	  	CursorI81x *hwcurs;
	  
	  	i81xenable(scr);
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	hwcurs = KADDR(scr->io+hwCur);
	+ 	hwcurs = (void*)((uchar*)scr->mmio+hwCur);
	  
	  	/*
	  	 * Initialise the 32x32 cursor to be transparent in 2bpp mode.
	  	 */
	- 	hwcurs->base = scr->storage;
	- 	p = KADDR(scr->storage);
	+ 	hwcurs->base = PADDR(scr->storage);
	+ 	p = (uchar*)scr->storage;
	  	for(i = 0; i < 32/2; i++) {
	  		memset(p, 0xff, 8);
	  		memset(p+8, 0, 8);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgai81x.c:269,275 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgai81x.c:219,225
	  	i81xenable,
	  	nil,
	  	nil,
	- 	i81xlinear,
	+ 	nil,
	  };
	  
	  VGAcur vgai81xcur = {
 [rsc] --rw-rw-r-- M 451989 rsc sys 2369 Nov  6 10:23 sys/src/9/pc/vgavesa.c
 [rsc] --rw-rw-r-- M 451989 presotto sys 7505 Nov  6 10:17 sys/src/9/pc/devlml.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devlml.c:127,132 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devlml.c:127,133
	  {
	  	Physseg segbuf;
	  	ulong regpa;
	+ 	void *regva;
	  	ISAConf isa;
	  	char name[32];
	  	Pcidev *pcidev;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/devlml.c:157,168 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/devlml.c:158,170
	  
	  		print("zr36067 found at 0x%.8lux", pcidev->mem[0].bar & ~0x0F);
	  
	- 		regpa = upamalloc(pcidev->mem[0].bar & ~0x0F, pcidev->mem[0].size, 0);
	- 		if (regpa == 0) {
	+ 		regpa = pcidev->mem[0].bar & ~0x0F;
	+ 		regva = vmap(regpa, pcidev->mem[0].size, 0);
	+ 		if (regva == 0) {
	  			print("lml: failed to map registers\n");
	  			return;
	  		}
	- 		lml->pciBaseAddr = (ulong)KADDR(regpa);
	+ 		lml->pciBaseAddr = (ulong)regva;
	  		print(", mapped at 0x%.8lux\n", lml->pciBaseAddr);
	  
	  		memset(&segbuf, 0, sizeof(segbuf));
 [rsc] --rw-rw-r-- M 451989 jmk sys 22723 Nov  6 10:19 sys/src/9/pc/ether8169.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8169.c:357,363 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8169.c:357,364
	  		ctlr->mii = nil;
	  		return -1;
	  	}
	- 	print("oui %X phyno %d\n", phy->oui, phy->phyno);
	+ 	USED(phy);
	+ 	// print("oui %X phyno %d\n", phy->oui, phy->phyno);
	  
	  	miiane(ctlr->mii, ~0, ~0, ~0);
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8169.c:451,458 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8169.c:452,459
	  	l += snprint(p+l, READSTR-l, "punlc: %ud\n", ctlr->punlc);
	  	l += snprint(p+l, READSTR-l, "fovw: %ud\n", ctlr->fovw);
	  
	- 	l += snprint(p+l, READSTR-l, "tcr: %8.8uX\n", ctlr->tcr);
	- 	l += snprint(p+l, READSTR-l, "rcr: %8.8uX\n", ctlr->rcr);
	+ 	l += snprint(p+l, READSTR-l, "tcr: %#8.8ux\n", ctlr->tcr);
	+ 	l += snprint(p+l, READSTR-l, "rcr: %#8.8ux\n", ctlr->rcr);
	  
	  	if(ctlr->mii != nil && ctlr->mii->curphy != nil){
	  		l += snprint(p+l, READSTR, "phy:   ");
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8169.c:460,466 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8169.c:461,467
	  			if(i && ((i & 0x07) == 0))
	  				l += snprint(p+l, READSTR-l, "\n       ");
	  			r = miimir(ctlr->mii, i);
	- 			l += snprint(p+l, READSTR-l, " %4.4uX", r);
	+ 			l += snprint(p+l, READSTR-l, " %4.4ux", r);
	  		}
	  		snprint(p+l, READSTR-l, "\n");
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8169.c:811,817 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8169.c:812,818
	  		else{
	  			/*
	  			 * Error stuff here.
	- 			print("control %8.8uX\n", control);
	+ 			print("control %#8.8ux\n", control);
	  			 */
	  		}
	  		d->control &= Eor;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8169.c:865,871 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8169.c:866,872
	  		 * Some of the reserved bits get set sometimes...
	  		 */
	  		if(isr & (Serr|Timeout|Tdu|Fovw|Punlc|Rdu|Ter|Tok|Rer|Rok))
	- 			panic("rtl8169interrupt: imr %4.4uX isr %4.4uX\n",
	+ 			panic("rtl8169interrupt: imr %#4.4ux isr %#4.4ux\n",
	  				csr16r(ctlr, Imr), isr);
	  	}
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ether8169.c:892,898 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ether8169.c:893,899
	  			continue;
	  
	  		if(ioalloc(port, p->mem[0].size, 0, "rtl8169") < 0){
	- 			print("rtl8169: port 0x%uX in use\n", port);
	+ 			print("rtl8169: port %#ux in use\n", port);
	  			continue;
	  		}
	  
 [rsc] --rw-rw-r-- M 451989 jmk sys 29128 Nov  6 10:19 sys/src/9/pc/etherdp83820.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherdp83820.c:1114,1120 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherdp83820.c:1114,1120
	  static void
	  dp83820pci(void)
	  {
	- 	int port;
	+ 	void *mem;
	  	Pcidev *p;
	  	Ctlr *ctlr;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherdp83820.c:1130,1147 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherdp83820.c:1130,1147
	  			break;
	  		}
	  
	- 		port = upamalloc(p->mem[1].bar & ~0x0F, p->mem[1].size, 0);
	- 		if(port == 0){
	+ 		mem = vmap(p->mem[1].bar & ~0x0F, p->mem[1].size);
	+ 		if(mem == 0){
	  			print("DP83820: can't map %8.8luX\n", p->mem[1].bar);
	  			continue;
	  		}
	  
	  		ctlr = malloc(sizeof(Ctlr));
	- 		ctlr->port = port;
	+ 		ctlr->port = p->mem[1].bar & ~0x0F;
	  		ctlr->pcidev = p;
	  		ctlr->id = (p->did<<16)|p->vid;
	  
	- 		ctlr->nic = KADDR(ctlr->port);
	+ 		ctlr->nic = mem;
	  		if(dp83820reset(ctlr)){
	  			free(ctlr);
	  			continue;
 [rsc] --rw-rw-r-- M 451989 presotto sys 28748 Nov  6 10:19 sys/src/9/pc/etherga620.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherga620.c:758,764 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherga620.c:758,764
	  	 * memory it is accessed via the Local Memory Window; with a send
	  	 * ring size of 128 the window covers the whole ring and then need
	  	 * only be set once:
	- 	 *	ctlr->sr = KADDR(ctlr->port+Lmw);
	+ 	 *	ctlr->sr = (uchar*)ctlr->nic+Lmw;
	  	 *	ga620lmw(ctlr, Sr, nil, sizeof(Sbd)*Nsr);
	  	 *	ctlr->gib->srcb.addr.lo = Sr;
	  	 * There is nowhere in the Sbd to hold the Block* associated
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherga620.c:1114,1120 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherga620.c:1114,1120
	  static void
	  ga620pci(void)
	  {
	- 	int port;
	+ 	void *mem;
	  	Pcidev *p;
	  	Ctlr *ctlr;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/etherga620.c:1135,1152 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/etherga620.c:1135,1152
	  			break;
	  		}
	  
	- 		port = upamalloc(p->mem[0].bar & ~0x0F, p->mem[0].size, 0);
	- 		if(port == 0){
	+ 		mem = vmap(p->mem[0].bar & ~0x0F, p->mem[0].size);
	+ 		if(mem == 0){
	  			print("ga620: can't map %8.8luX\n", p->mem[0].bar);
	  			continue;
	  		}
	  
	  		ctlr = malloc(sizeof(Ctlr));
	- 		ctlr->port = port;
	+ 		ctlr->port = p->mem[0].bar & ~0x0F;
	  		ctlr->pcidev = p;
	  		ctlr->id = (p->did<<16)|p->vid;
	  
	- 		ctlr->nic = KADDR(ctlr->port);
	+ 		ctlr->nic = mem;
	  		if(ga620reset(ctlr)){
	  			free(ctlr);
	  			continue;
 [rsc] --rw-rw-r-- M 451989 jmk sys 22572 Nov  6 10:19 sys/src/9/pc/ethervt6102.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/ethervt6102.c:925,931 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/ethervt6102.c:925,931
	  		ctlr->mii = nil;
	  		return -1;
	  	}
	- 	print("oui %X phyno %d\n", phy->oui, phy->phyno);
	+ 	// print("oui %X phyno %d\n", phy->oui, phy->phyno);
	  
	  	//miiane(ctlr->mii, ~0, ~0, ~0);
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 1418 Nov  6 10:21 sys/src/9/pc/pccd
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pccd:61,66 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pccd:61,67
	  	usbuhci
	  
	  misc
	+ 	realmode
	  	archmp		mp apic
	  
	  	sdata		pci sdscsi
 [rsc] --rw-rw-r-- M 451989 presotto sys 1486 Nov  6 12:59 sys/src/9/pc/pccpuf
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pccpuf:58,63 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pccpuf:58,64
	  	usbuhci
	  
	  misc
	+ 	realmode
	  	archmp		mp apic
	  
	  	uarti8250
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pccpuf:86,91 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pccpuf:87,93
	  	vgat2r4		+cur
	  	vgatvp3020	=cur
	  	vgatvp3026	=cur
	+ 	vgavesa
	  	vgavmware	+cur
	  
	  
 [rsc] --rw-rw-r-- M 451989 rsc sys 1473 Nov  6 12:59 sys/src/9/pc/pcflop
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pcflop:62,67 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pcflop:62,68
	  #	usbuhci
	  
	  misc
	+ 	realmode
	  #	archmp		mp apic
	  
	  	sdata		pci sdscsi
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/pcflop:91,96 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/pcflop:92,98
	  	vgat2r4		+cur
	  	vgatvp3020	=cur
	  	vgatvp3026	=cur
	+ 	vgavesa
	  	vgavmware	+cur
	  
	  ip
 [rsc] --rw-rw-r-- M 451989 rsc sys 25780 Nov  6 10:23 sys/src/9/pc/sdmv50xx.c
 [rsc] --rw-rw-r-- M 451989 glenda sys 5148 Nov  6 10:23 sys/src/9/pc/vga.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga.c:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga.c:3,9
	  #include "mem.h"
	  #include "dat.h"
	  #include "fns.h"
	+ #include "io.h"
	  #include "../port/error.h"
	  
	  #define	Image	IMAGE
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga.c:18,24 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga.c:19,25
	  static Rectangle window;
	  static int *xp;
	  static int xbuf[256];
	- static Lock vgascreenlock;
	+ Lock vgascreenlock;
	  int drawdebug;
	  
	  void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga.c:136,142 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga.c:137,143
	  static void
	  vgascreenputs(char* s, int n)
	  {
	- 	int i;
	+ 	int i, gotdraw;
	  	Rune r;
	  	char buf[4];
	  	VGAscr *scr;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga.c:155,160 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga.c:156,167
	  	else
	  		lock(&vgascreenlock);
	  
	+ 	/*
	+ 	 * Be nice to hold this, but not going to deadlock
	+ 	 * waiting for it.  Just try and see.
	+ 	 */
	+ 	gotdraw = canqlock(&drawlock);
	+ 
	  	flushr = Rect(10000, 10000, -10000, -10000);
	  
	  	while(n > 0){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga.c:172,177 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga.c:179,186
	  	}
	  	flushmemscreen(flushr);
	  
	+ 	if(gotdraw)
	+ 		qunlock(&drawlock);
	  	unlock(&vgascreenlock);
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga.c:241,247 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga.c:250,256
	  	Point p;
	  
	  	scr = &vgascreen[0];
	- 	if(scr->aperture == 0 || screenputs != vgascreenputs)
	+ 	if(scr->vaddr == nil || screenputs != vgascreenputs)
	  		return;
	  	p = memsubfontwidth(scr->memdefont, s);
	  	w = p.x;
 [rsc] --rw-rw-r-- M 451989 glenda sys 3833 Nov  6 10:23 sys/src/9/pc/vga3dfx.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga3dfx.c:28,93 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga3dfx.c:28,40
	  	hwCur		= 0x5C,
	  };
	  
	- static ulong
	- tdfxlinear(VGAscr* scr, int* size, int* align)
	- {
	- 	Pcidev *p;
	- 	int oapsize, wasupamem;
	- 	ulong aperture, oaperture;
	- 
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	aperture = 0;
	- 	if(p = pcimatch(nil, 0x121A, 0)){
	- 		switch(p->did){
	- 		case 0x0003:		/* Banshee */
	- 		case 0x0005:		/* Avenger (a.k.a. Voodoo3) */
	- 		case 0x0009:		/* Voodoo5 */
	- 			aperture = p->mem[1].bar & ~0x0F;
	- 			*size = p->mem[1].size;
	- 			break;
	- 		default:
	- 			break;
	- 		}
	- 	}
	- 
	- 	if(wasupamem){
	- 		if(oaperture == aperture)
	- 			return oaperture;
	- 		upafree(oaperture, oapsize);
	- 	}
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0)){
	- 			aperture = oaperture;
	- 			scr->isupamem = 1;
	- 		}
	- 		else
	- 			scr->isupamem = 0;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	return aperture;
	- }
	- 
	  static void
	  tdfxenable(VGAscr* scr)
	  {
	  	Pcidev *p;
	- 	ulong aperture;
	- 	int align, i, *mmio, size;
	+ 	int i, *mmio;
	  
	- 	/*
	- 	 * Only once, can't be disabled for now.
	- 	 * scr->io holds the physical address of
	- 	 * the MMIO registers.
	- 	 */
	- 	if(scr->io)
	+ 	if(scr->mmio)
	  		return;
	  	if(p = pcimatch(nil, 0x121A, 0)){
	  		switch(p->did){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga3dfx.c:100,120 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga3dfx.c:47,63
	  	}
	  	else
	  		return;
	- 	scr->io = upamalloc(p->mem[0].bar & ~0x0F, p->mem[0].size, 0);
	- 	if(scr->io == 0)
	+ 	
	+ 	scr->mmio = vmap(p->mem[0].bar&~0x0F, p->mem[0].size);
	+ 	if(scr->mmio == nil)
	  		return;
	+ 	scr->pci = p;
	+ 	
	+ 	addvgaseg("3dfxmmio", p->mem[0].bar&~0x0F, p->mem[0].size);
	+ 	vgalinearpci(scr);
	+ 	if(scr->apsize)
	+ 		addvgaseg("3dfxscreen", scr->paddr, scr->apsize);
	  
	- 	addvgaseg("3dfxmmio", (ulong)scr->io, p->mem[0].size);
	- 
	- 	size = p->mem[1].size;
	- 	align = 0;
	- 	aperture = tdfxlinear(scr, &size, &align);
	- 	if(aperture){
	- 		scr->aperture = aperture;
	- 		scr->apsize = size;
	- 		addvgaseg("3dfxscreen", aperture, size);
	- 	}
	- 
	  	/*
	  	 * Find a place for the cursor data in display memory.
	  	 * If SDRAM then there's 16MB memory else it's SGRAM
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga3dfx.c:123,129 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga3dfx.c:66,72
	  	 * 8 of them.
	  	 * Use the last 1KB of the framebuffer.
	  	 */
	- 	mmio = KADDR(scr->io + dramInit0);
	+ 	mmio = (void*)((uchar*)scr->mmio+dramInit0);
	  	if(*(mmio+1) & 0x40000000)
	  		i = 16*1024*1024;
	  	else{
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga3dfx.c:144,152 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga3dfx.c:87,95
	  {
	  	Cursor3dfx *cursor3dfx;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	cursor3dfx = KADDR(scr->io+hwCur);
	+ 	cursor3dfx = (void*)((uchar*)scr->mmio+hwCur);
	  	cursor3dfx->vidProcCfg &= ~0x08000000;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga3dfx.c:157,165 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga3dfx.c:100,108
	  	uchar *p;
	  	Cursor3dfx *cursor3dfx;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	cursor3dfx = KADDR(scr->io+hwCur);
	+ 	cursor3dfx = (void*)((uchar*)scr->mmio+hwCur);
	  
	  	/*
	  	 * Disable the cursor then load the new image in
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga3dfx.c:177,183 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga3dfx.c:120,126
	  	 * transparent.
	  	 */
	  	cursor3dfx->vidProcCfg &= ~0x08000000;
	- 	p = KADDR(scr->aperture + scr->storage);
	+ 	p = (uchar*)scr->vaddr + scr->storage;
	  	for(y = 0; y < 16; y++){
	  		*p++ = curs->clr[2*y]|curs->set[2*y];
	  		*p++ = curs->clr[2*y+1]|curs->set[2*y+1];
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga3dfx.c:201,209 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga3dfx.c:144,152
	  {
	  	Cursor3dfx *cursor3dfx;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return 1;
	- 	cursor3dfx = KADDR(scr->io+hwCur);
	+ 	cursor3dfx = (void*)((uchar*)scr->mmio+hwCur);
	  
	  	cursor3dfx->hwCurLoc = ((p.y+scr->offset.y)<<16)|(p.x+scr->offset.x);
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga3dfx.c:216,224 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga3dfx.c:159,167
	  	Cursor3dfx *cursor3dfx;
	  
	  	tdfxenable(scr);
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	cursor3dfx = KADDR(scr->io+hwCur);
	+ 	cursor3dfx = (void*)((uchar*)scr->mmio+hwCur);
	  
	  	/*
	  	 * Cursor colours.
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga3dfx.c:230,236 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga3dfx.c:173,179
	  	 * Initialise the 64x64 cursor to be transparent (X11 mode).
	  	 */
	  	cursor3dfx->hwCurPatAddr = scr->storage;
	- 	memset(KADDR(scr->aperture + scr->storage), 0, 64*16);
	+ 	memset((uchar*)scr->vaddr + scr->storage, 0, 64*16);
	  
	  	/*
	  	 * Load, locate and enable the 64x64 cursor in X11 mode.
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vga3dfx.c:246,252 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vga3dfx.c:189,195
	  	tdfxenable,
	  	nil,
	  	nil,
	- 	tdfxlinear,
	+ 	nil,
	  };
	  
	  VGAcur vga3dfxcur = {
 [rsc] --rw-rw-r-- M 451989 glenda sys 3422 Nov  6 10:23 sys/src/9/pc/vgaark2000pv.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaark2000pv.c:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaark2000pv.c:3,9
	  #include "mem.h"
	  #include "dat.h"
	  #include "fns.h"
	+ #include "io.h"
	  #include "../port/error.h"
	  
	  #define	Image	IMAGE
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaark2000pv.c:90,96 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaark2000pv.c:91,97
	  	 */
	  	seq10 = vgaxi(Seqx, 0x10);
	  	opage = 0;
	- 	p = KADDR(scr->aperture);
	+ 	p = scr->vaddr;
	  	if(!(seq10 & 0x10)){
	  		lock(&scr->devlock);
	  		opage = ark2000pvpageset(scr, scr->storage>>16);
 [rsc] --rw-rw-r-- M 451989 glenda sys 5057 Nov  6 10:23 sys/src/9/pc/vgabt485.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgabt485.c:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgabt485.c:3,9
	  #include "mem.h"
	  #include "dat.h"
	  #include "fns.h"
	+ #include "io.h"
	  #include "../port/error.h"
	  
	  #define	Image	IMAGE
 [rsc] --rw-rw-r-- M 451989 glenda sys 4550 Nov  6 10:23 sys/src/9/pc/vgaclgd542x.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaclgd542x.c:41,76 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaclgd542x.c:41,50
	  	unlock(&scr->devlock);
	  }
	  
	- static ulong
	- clgd542xlinear(VGAscr* scr, int* size, int* align)
	+ static void
	+ clgd542xlinear(VGAscr* scr, int, int)
	  {
	- 	ulong aperture, oaperture;
	- 	int oapsize, wasupamem;
	- 	Pcidev *p;
	- 
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 	if(wasupamem)
	- 		upafree(oaperture, oapsize);
	- 	scr->isupamem = 0;
	- 
	- 	if(p = pcimatch(nil, 0x1013, 0)){
	- 		aperture = p->mem[0].bar & ~0x0F;
	- 		*size = p->mem[0].size;
	- 	}
	- 	else
	- 		aperture = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0))
	- 			scr->isupamem = 1;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	return aperture;
	+ 	vgalinearpciid(scr, 0x1013, 0);
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaclgd542x.c:171,177 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaclgd542x.c:145,151
	  	 */
	  	seq07 = vgaxi(Seqx, 0x07);
	  	opage = 0;
	- 	p = KADDR(scr->aperture);
	+ 	p = scr->vaddr;
	  	if(!(seq07 & 0xF0)){
	  		lock(&scr->devlock);
	  		opage = clgd542xpageset(scr, scr->storage>>16);
 [rsc] --rw-rw-r-- M 451989 glenda sys 3716 Nov  6 10:23 sys/src/9/pc/vgaclgd546x.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaclgd546x.c:26,118 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaclgd546x.c:26,60
	  	CursorMMIO	= 0xE0,
	  };
	  
	- static ulong
	- clgd546xlinear(VGAscr* scr, int* size, int* align)
	+ static void
	+ clgd546xlinear(VGAscr* scr, int, int)
	  {
	- 	ulong aperture, oaperture;
	- 	int oapsize, wasupamem;
	- 	Pcidev *p;
	- 
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	aperture = 0;
	- 	if(p = pcimatch(nil, 0x1013, 0)){
	- 		switch(p->did){
	- 		case 0xD0:
	- 		case 0xD4:
	- 		case 0xD6:
	- 			aperture = p->mem[0].bar & ~0x0F;
	- 			*size = p->mem[0].size;
	- 			break;
	- 		default:
	- 			break;
	- 		}
	- 	}
	- 
	- 	if(wasupamem){
	- 		if(oaperture == aperture)
	- 			return oaperture;
	- 		upafree(oaperture, oapsize);
	- 	}
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0)){
	- 			aperture = oaperture;
	- 			scr->isupamem = 1;
	- 		}
	- 		else
	- 			scr->isupamem = 0;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	return aperture;
	+ 	vgalinearpci(scr);
	  }
	+ 
	  static void
	  clgd546xenable(VGAscr* scr)
	  {
	  	Pcidev *p;
	- 	int size, align;
	- 	ulong aperture;
	  
	- 	/*
	- 	 * Only once, can't be disabled for now.
	- 	 * scr->io holds the virtual address of
	- 	 * the MMIO registers.
	- 	 */
	- 	if(scr->io)
	+ 	if(scr->mmio)
	  		return;
	- 	if(p = pcimatch(nil, 0x1013, 0)){
	- 		switch(p->did){
	- 		case 0xD0:
	- 		case 0xD4:
	- 		case 0xD6:
	- 			break;
	- 		default:
	- 			return;
	- 		}
	- 	}
	- 	else
	+ 	if((p = pcimatch(nil, 0x1013, 0)) == nil)
	  		return;
	- 	scr->io = upamalloc(p->mem[1].bar & ~0x0F, p->mem[1].size, 0);
	- 	if(scr->io == 0)
	+ 	switch(p->did){
	+ 	case 0xD0:
	+ 	case 0xD4:
	+ 	case 0xD6:
	+ 		break;
	+ 	default:
	  		return;
	- 	addvgaseg("clgd546xmmio", scr->io, p->mem[1].size);
	- 
	- 	scr->io = (ulong)KADDR(scr->io);
	- 
	- 	size = p->mem[0].size;
	- 	align = 0;
	- 	aperture = clgd546xlinear(scr, &size, &align);
	- 	if(aperture) {
	- 		scr->aperture = aperture;
	- 		scr->apsize = size;
	- 		addvgaseg("clgd546xscreen", aperture, size);
	  	}
	+ 
	+ 	scr->pci = p;
	+ 	scr->mmio = vmap(p->mem[1].bar&~0x0F, p->mem[1].size);
	+ 	if(scr->mmio == 0)
	+ 		return;
	+ 	addvgaseg("clgd546xmmio", p->mem[1].bar&~0x0F, p->mem[1].size);
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaclgd546x.c:120,128 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaclgd546x.c:62,70
	  {
	  	Cursor546x *cursor546x;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	cursor546x = (Cursor546x*)(scr->io+CursorMMIO);
	+ 	cursor546x = (Cursor546x*)((uchar*)scr->mmio+CursorMMIO);
	  	cursor546x->enable = 0;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaclgd546x.c:133,141 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaclgd546x.c:75,83
	  	uchar *p;
	  	Cursor546x *cursor546x;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	cursor546x = (Cursor546x*)(scr->io+CursorMMIO);
	+ 	cursor546x = (Cursor546x*)((uchar*)scr->mmio+CursorMMIO);
	  
	  	/*
	  	 * Disable the cursor then change only the bits
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaclgd546x.c:142,148 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaclgd546x.c:84,90
	  	 * that need it.
	  	 */
	  	cursor546x->enable = 0;
	- 	p = (uchar*)(scr->aperture + scr->storage);
	+ 	p = (uchar*)scr->vaddr + scr->storage;
	  	for(y = 0; y < 16; y++){
	  		c = curs->set[2*y];
	  		m = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaclgd546x.c:189,197 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaclgd546x.c:131,139
	  	int x, xo, y, yo;
	  	Cursor546x *cursor546x;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return 1;
	- 	cursor546x = (Cursor546x*)(scr->io+CursorMMIO);
	+ 	cursor546x = (Cursor546x*)((uchar*)scr->mmio+CursorMMIO);
	  
	  	if((x = p.x+scr->offset.x) < 0){
	  		xo = -x;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaclgd546x.c:220,234 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaclgd546x.c:162,176
	  	Cursor546x *cursor546x;
	  
	  	clgd546xenable(scr);
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	cursor546x = (Cursor546x*)(scr->io+CursorMMIO);
	+ 	cursor546x = (Cursor546x*)((uchar*)scr->mmio+CursorMMIO);
	  
	  	/*
	  	 * Cursor colours.
	  	 * Can't call setcolor here as cursor is already locked.
	  	 */
	- 	p = (uchar*)(scr->io+PaletteState);
	+ 	p = (uchar*)scr->mmio+PaletteState;
	  	*p |= 0x08;
	  	vgao(PaddrW, 0x00);
	  	vgao(Pdata, Pwhite);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaclgd546x.c:248,254 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaclgd546x.c:190,196
	  	 */
	  	scr->storage = ((vgaxi(Seqx, 0x14) & 0x07)+1)*1024*1022;
	  	cursor546x->addr = (scr->storage>>10)<<2;
	- 	memset((uchar*)(scr->aperture + scr->storage), 0, 2*64*16);
	+ 	memset((uchar*)scr->vaddr + scr->storage, 0, 2*64*16);
	  
	  	/*
	  	 * Load, locate and enable the 64x64 cursor.
 [rsc] --rw-rw-r-- M 451989 glenda sys 2249 Nov  6 10:23 sys/src/9/pc/vgact65545.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgact65545.c:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgact65545.c:3,9
	  #include "mem.h"
	  #include "dat.h"
	  #include "fns.h"
	+ #include "io.h"
	  #include "../port/error.h"
	  
	  #define	Image	IMAGE
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgact65545.c:52,58 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgact65545.c:53,59
	  	uint and, clr, set, xor;
	  	int i, x, y;
	  
	- 	mem = KADDR(scr->aperture);
	+ 	mem = scr->vaddr;
	  	mem += scr->storage + index*1024;
	  
	  	for(y = yo; y < 16; y++){
 [rsc] --rw-rw-r-- M 451989 glenda sys 3707 Nov  6 10:23 sys/src/9/pc/vgacyber938x.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgacyber938x.c:38,87 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgacyber938x.c:38,65
	  	unlock(&scr->devlock);
	  }
	  
	- static ulong
	- cyber938xlinear(VGAscr* scr, int* size, int* align)
	+ static void
	+ cyber938xlinear(VGAscr* scr, int, int)
	  {
	- 	ulong aperture, oaperture;
	- 	int oapsize, wasupamem;
	- 	int osize;
	  	Pcidev *p;
	  
	- 	osize = *size;
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 	if(wasupamem)
	- 		upafree(oaperture, oapsize);
	- 	scr->isupamem = 0;
	- 	scr->mmio = 0;
	+ 	if(scr->vaddr)
	+ 		return;
	+ 	
	+ 	vgalinearpciid(scr, 0x1023, 0);
	+ 	p = scr->pci;
	  
	- 	if(p = pcimatch(nil, 0x1023, 0)){
	- 		aperture = p->mem[0].bar & ~0x0F;
	- 		*size = p->mem[0].size;
	- 		/*
	- 		 * Heuristic to detect the MMIO space.  We're flying blind
	- 		 * here, with only the XFree86 source to guide us.
	- 		 */
	- 		if(p->mem[1].size == 0x20000)
	- 			scr->mmio = (ulong*)(p->mem[1].bar & ~0x0F);
	- 	}
	- 	else
	- 		aperture = 0;
	+ 	/*
	+ 	 * Heuristic to detect the MMIO space.  We're flying blind
	+ 	 * here, with only the XFree86 source to guide us.
	+ 	 */
	+ 	if(p->mem[1].size == 0x20000)
	+ 		scr->mmio = vmap(p->mem[1].bar & ~0x0F, p->mem[1].size);
	  
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0))
	- 			scr->isupamem = 1;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	if(aperture)
	- 		addvgaseg("cyber938xscreen", aperture, osize);
	+ 	if(scr->apsize)
	+ 		addvgaseg("cyber938xscreen", scr->paddr, scr->apsize);
	  	if(scr->mmio)
	- 		addvgaseg("cyber938xmmio", (ulong)scr->mmio, 0x20000);
	- 
	- 	return aperture;
	+ 		addvgaseg("cyber938xmmio", p->mem[1].bar&~0x0F, 0x20000);
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgacyber938x.c:99,105 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgacyber938x.c:77,83
	  	cyber938xcurdisable(scr);
	  
	  	opage = 0;
	- 	p = KADDR(scr->aperture);
	+ 	p = scr->vaddr;
	  	islinear = vgaxi(Crtx, 0x21) & 0x20;
	  	if(!islinear){
	  		lock(&scr->devlock);
 [rsc] --rw-rw-r-- M 451989 glenda sys 5111 Nov  6 10:23 sys/src/9/pc/vgaet4000.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaet4000.c:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaet4000.c:3,9
	  #include "mem.h"
	  #include "dat.h"
	  #include "fns.h"
	+ #include "io.h"
	  #include "../port/error.h"
	  
	  #define	Image	IMAGE
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgaet4000.c:139,145 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgaet4000.c:140,146
	  	et4000disable(scr);
	  
	  	setet4000page(scr->storage>>16);
	- 	mem = (uchar*)KADDR(scr->aperture) + (scr->storage & 0xFFFF);
	+ 	mem = (uchar*)scr->vaddr + (scr->storage & 0xFFFF);
	  
	  	/*
	  	 * Initialise the 64x64 cursor RAM array. There are 2 planes,
 [rsc] --rw-rw-r-- M 451989 glenda sys 4098 Nov  6 10:23 sys/src/9/pc/vgahiqvideo.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgahiqvideo.c:34,85 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgahiqvideo.c:34,42
	  	outb(port+1, data);
	  }
	  
	- static ulong
	- hiqvideolinear(VGAscr* scr, int* size, int* align)
	+ static void
	+ hiqvideolinear(VGAscr*, int, int)
	  {
	- 	ulong aperture, oaperture;
	- 	int oapsize, wasupamem;
	- 	Pcidev *p;
	- 
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	aperture = 0;
	- 	if(p = pcimatch(nil, 0x102C, 0)){
	- 		switch(p->did){
	- 		case 0x00C0:		/* 69000 HiQVideo */
	- 		case 0x00E0:		/* 65550 HiQV32 */
	- 		case 0x00E4:		/* 65554 HiQV32 */
	- 		case 0x00E5:		/* 65555 HiQV32 */
	- 			aperture = p->mem[0].bar & ~0x0F;
	- 			*size = p->mem[0].size;
	- 			break;
	- 		default:
	- 			break;
	- 		}
	- 	}
	- 
	- 	if(wasupamem){
	- 		if(oaperture == aperture)
	- 			return oaperture;
	- 		upafree(oaperture, oapsize);
	- 	}
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0)){
	- 			aperture = oaperture;
	- 			scr->isupamem = 1;
	- 		}
	- 		else
	- 			scr->isupamem = 0;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	return aperture;
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgahiqvideo.c:86,98 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgahiqvideo.c:43,54
	  hiqvideoenable(VGAscr* scr)
	  {
	  	Pcidev *p;
	- 	int align, size, vmsize;
	- 	ulong aperture;
	+ 	int vmsize;
	  
	  	/*
	  	 * Only once, can't be disabled for now.
	  	 */
	- 	if(scr->io)
	+ 	if(scr->mmio)
	  		return;
	  	if(p = pcimatch(nil, 0x102C, 0)){
	  		switch(p->did){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgahiqvideo.c:119,141 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgahiqvideo.c:75,95
	  	else
	  		return;
	  
	- 	size = p->mem[0].size;
	- 	align = 0;
	- 	aperture = hiqvideolinear(scr, &size, &align);
	- 	if(aperture) {
	- 		scr->aperture = aperture;
	- 		scr->apsize = size;
	- 		addvgaseg("hiqvideoscreen", aperture, size);
	+ 	scr->pci = p;
	+ 	vgalinearpci(scr);
	+ 	
	+ 	if(scr->paddr) {
	+ 		addvgaseg("hiqvideoscreen", scr->paddr, scr->apsize);
	  	}
	  
	  	/*
	  	 * Find a place for the cursor data in display memory.
	  	 * Must be on a 4096-byte boundary.
	- 	 * scr->io holds the physical address of the cursor
	+ 	 * scr->mmio holds the virtual address of the cursor
	  	 * storage area in the framebuffer region.
	  	 */
	  	scr->storage = vmsize-4096;
	- 	scr->io = scr->aperture+scr->storage;
	+ 	scr->mmio = (ulong*)((uchar*)scr->vaddr+scr->storage);
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgahiqvideo.c:155,163 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgahiqvideo.c:109,117
	  	 */
	  	hiqvideocurdisable(scr);
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	p = KADDR(scr->io);
	+ 	p = (uchar*)scr->mmio;
	  
	  	for(y = 0; y < 16; y += 2){
	  		*p++ = ~(curs->clr[2*y]|curs->set[2*y]);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgahiqvideo.c:197,203 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgahiqvideo.c:151,157
	  {
	  	int x, y;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return 1;
	  
	  	if((x = p.x+scr->offset.x) < 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgahiqvideo.c:219,225 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgahiqvideo.c:173,179
	  	uchar xr80;
	  
	  	hiqvideoenable(scr);
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	  
	  	/*
 [rsc] --rw-rw-r-- M 451989 glenda sys 28257 Nov  6 10:23 sys/src/9/pc/vgamach64xx.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamach64xx.c:168,180 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamach64xx.c:168,178
	  {
	  	Pcidev *p;
	  
	- 	/*
	- 	 * Only once, can't be disabled for now.
	- 	 */
	  	if(scr->io)
	  		return;
	  	if(p = mach64xxpci()){
	  		scr->id = p->did;
	+ 		scr->pci = p;
	  
	  		/*
	  		 * The CT doesn't always have the I/O base address
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamach64xx.c:189,241 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamach64xx.c:187,201
	  	}
	  }
	  
	- static ulong
	- mach64xxlinear(VGAscr* scr, int* size, int* align)
	+ static void
	+ mach64xxlinear(VGAscr* scr, int size, int)
	  {
	- 	ulong aperture, osize, oaperture;
	- 	int i, oapsize, wasupamem;
	- 	Pcidev *p;
	- 
	- 	osize = *size;
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	if(p = mach64xxpci()){
	- 		for(i=0; i<nelem(p->mem); i++){
	- 			if(p->mem[i].size >= *size
	- 			&& ((p->mem[i].bar & ~0x0F) & (*align-1)) == 0)
	- 				break;
	- 		}
	- 		if(i >= nelem(p->mem)){
	- 			print("vgamach64xx: aperture not found\n");
	- 			return 0;
	- 		}
	- 		aperture = p->mem[i].bar & ~0x0F;
	- 		*size = p->mem[i].size;
	- 	}
	- 	else
	- 		aperture = 0;
	- 
	- 	if(wasupamem)
	- 		upafree(oaperture, oapsize);
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0))
	- 			scr->isupamem = 1;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	scr->mmio = KADDR(aperture+osize-0x400);
	- 	if(oaperture && oaperture != aperture)
	- 		print("warning (BUG): redefinition of aperture does not change mach64mmio segment\n");
	- 	addvgaseg("mach64mmio", aperture+osize-BY2PG, BY2PG);
	- 	addvgaseg("mach64screen", aperture, osize);
	- 
	- 	return aperture;
	+ 	vgalinearpci(scr);
	+ 	if(scr->paddr == 0)
	+ 		return;
	+ 	scr->mmio = (ulong*)((uchar*)scr->vaddr+size-1024);
	+ 	addvgaseg("mach64mmio", scr->paddr+size-BY2PG, BY2PG);
	+ 	addvgaseg("mach64screen", scr->paddr, scr->apsize);
	  }
	  
	  enum {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamach64xx.c:474,480 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamach64xx.c:434,440
	  	r = ior32(scr, GenTestCntl);
	  	iow32(scr, GenTestCntl, r & ~0x80);
	  
	- 	p = KADDR(scr->aperture);
	+ 	p = scr->vaddr;
	  	p += scr->storage;
	  
	  	/*
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamach64xx.c:792,798 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamach64xx.c:752,758
	  	}
	  
	  	/* Get the base freq from the BIOS */
	- 	bios  = KADDR(0xC000);
	+ 	bios  = kaddr(0xC000);
	  	table = *(ushort *)(bios + 0x48);
	  	table = *(ushort *)(bios + table + 0x10);
	  	switch (*(ushort *)(bios + table + 0x08)) {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamach64xx.c:1120,1126 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamach64xx.c:1080,1086
	  		   mach64revb? "yes": "no",
	  		   mach64refclock);
	  	pprint("%s: storage @%.8luX, aperture @%8.ulX, ovl buf @%.8ulX\n",
	- 		   scr->dev->name, scr->storage, scr->aperture,
	+ 		   scr->dev->name, scr->storage, scr->paddr,
	  		   mach64overlay);
	  }
	  	
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamach64xx.c:1215,1221 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamach64xx.c:1175,1181
	  
	  		_offs = (ulong)(offs % ovl_fib);
	  		nb     = (_offs + len > ovl_fib)? ovl_fib - _offs: len;
	- 		memmove((uchar *)KADDR(scr->aperture + mach64overlay + _offs), 
	+ 		memmove((uchar *)scr->vaddr + mach64overlay + _offs, 
	  				  src, nb);
	  		offs += nb;
	  		src  += nb;
 [rsc] --rw-rw-r-- M 451989 glenda sys 4637 Nov  6 10:23 sys/src/9/pc/vgamga2164w.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga2164w.c:42,100 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga2164w.c:42,53
	  	return p;
	  }
	  
	- static ulong
	- mga2164wlinear(VGAscr* scr, int* size, int* align)
	- {
	- 	ulong aperture, oaperture;
	- 	int oapsize, wasupamem;
	- 	Pcidev *p;
	- 
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	if(p = mgapcimatch()){
	- 		aperture = p->mem[p->did==MGA2064? 1 : 0].bar & ~0x0F;
	- 		*size = (p->did==MGA2064? 8 :16)*1024*1024;
	- 	}
	- 	else
	- 		aperture = 0;
	- 
	- 	if(wasupamem) {
	- 		if(oaperture == aperture)
	- 			return oaperture;
	- 		upafree(oaperture, oapsize);
	- 	}
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0)) {
	- 			aperture = oaperture;
	- 			scr->isupamem = 1;
	- 		}
	- 		else
	- 			scr->isupamem = 0;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	return aperture;
	- }
	- 
	  static void
	  mga2164wenable(VGAscr* scr)
	  {
	  	Pcidev *p;
	- 	int size, align, immio;
	- 	ulong aperture;
	  
	- 	/*
	- 	 * Only once, can't be disabled for now.
	- 	 * scr->io holds the virtual address of
	- 	 * the MMIO registers.
	- 	 */
	- 	if(scr->io)
	+ 	if(scr->mmio)
	  		return;
	  
	  	p = mgapcimatch();
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga2164w.c:101,123 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga2164w.c:54,72
	  	if(p == nil)
	  		return;
	  
	- 	immio = p->did==MGA2064? 0 : 1;
	- 	scr->io = upamalloc(p->mem[immio].bar & ~0x0F, p->mem[immio].size, 0);
	- 	if(scr->io == 0)
	- 		return;
	- 	addvgaseg("mga2164wmmio", scr->io, p->mem[immio].size);
	- 
	- 	scr->io = (ulong)KADDR(scr->io);
	- 
	- 	/* need to map frame buffer here too, so vga can find memory size */
	- 	size = (p->did==MGA2064? 8 :16)*1024*1024;
	- 	align = 0;
	- 	aperture = mga2164wlinear(scr, &size, &align);
	- 	if(aperture) {
	- 		scr->aperture = aperture;
	- 		scr->apsize = size;
	- 		addvgaseg("mga2164wscreen", aperture, size);
	+ 	if(p->did == MGA2064){
	+ 		scr->mmio = vmap(p->mem[0].bar&~0x0F, p->mem[0].size);
	+ 		if(scr->mmio == nil)
	+ 			return;
	+ 		vgalinearaddr(scr, p->mem[1].bar&~0x0F, 8*MB);
	+ 	}else{
	+ 		scr->mmio = vmap(p->mem[1].bar&~0x0F, p->mem[1].size);
	+ 		if(scr->mmio == nil)
	+ 			return;
	+ 		vgalinearaddr(scr, p->mem[0].bar&~0x0F, 16*MB);
	  	}
	+ 	if(scr->paddr)
	+ 		addvgaseg("mga2164wscreen", scr->paddr, scr->apsize);
	  }
	  
	  enum {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga2164w.c:142,150 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga2164w.c:91,99
	  {
	  	uchar *tvp3026;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	tvp3026 = KADDR(scr->io+0x3C00);
	+ 	tvp3026 = (uchar*)scr->mmio+0x3C00;
	  
	  	/*
	  	 * Make sure cursor is off
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga2164w.c:161,169 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga2164w.c:110,118
	  	int x, y;
	  	uchar *tvp3026;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	tvp3026 = KADDR(scr->io+0x3C00);
	+ 	tvp3026 = (uchar*)scr->mmio+0x3C00;
	  
	  	/*
	  	 * Make sure cursor is off by initialising the cursor
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga2164w.c:223,231 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga2164w.c:172,180
	  	int x, y;
	  	uchar *tvp3026;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return 1;
	- 	tvp3026 = KADDR(scr->io+0x3C00);
	+ 	tvp3026 = (uchar*)scr->mmio+0x3C00;
	  
	  	x = p.x+scr->offset.x;
	  	y = p.y+scr->offset.y;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga2164w.c:244,252 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga2164w.c:193,201
	  	int i;
	  	uchar *tvp3026;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	tvp3026 = KADDR(scr->io+0x3C00);
	+ 	tvp3026 = (uchar*)scr->mmio+0x3C00;
	  
	  	tvp3026disable(scr);
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga2164w.c:276,282 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga2164w.c:225,231
	  	mga2164wenable,			/* enable */
	  	0,				/* disable */
	  	0,				/* page */
	- 	mga2164wlinear,			/* linear */
	+ 	0,				/* linear */
	  };
	  
	  VGAcur vgamga2164wcur = {
 [rsc] --rw-rw-r-- M 451989 glenda sys 10201 Nov  6 10:23 sys/src/9/pc/vgamga4xx.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:23,31 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:23,28
	  	MGA4xx			= 0x0525,
	  	MGA200			= 0x0521,
	  
	- 	Kilo				= 1024,
	- 	Meg				= 1024*1024,
	- 
	  	FCOL			= 0x1c24,
	  	FXRIGHT			= 0x1cac,	
	  	FXLEFT			= 0x1ca8,
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:91,149 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:88,104
	  	return p;
	  }
	  
	- static ulong
	- mga4xxlinear(VGAscr* scr, int* size, int* align)
	- {
	- 	ulong 	aperture, oaperture;
	- 	int 		oapsize, wasupamem;
	- 	Pcidev *	p;
	  
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	if(p = mgapcimatch()){
	- 		aperture = p->mem[0].bar & ~0x0F;
	- 		if(p->did == MGA4xx)
	- 			*size = 32*Meg;
	- 		else
	- 			*size = 8*Meg;
	- 	}
	- 	else
	- 		aperture = 0;
	- 
	- 	if(wasupamem) {
	- 		if(oaperture == aperture)
	- 			return oaperture;
	- 		upafree(oaperture, oapsize);
	- 	}
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0)) {
	- 			aperture = oaperture;
	- 			scr->isupamem = 1;
	- 		}
	- 		else
	- 			scr->isupamem = 0;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	return aperture;
	- }
	- 
	  static void
	  mgawrite8(VGAscr* scr, int index, uchar val)
	  {
	- 	((uchar*)scr->io)[index] = val;
	+ 	((uchar*)scr->mmio)[index] = val;
	  }
	  
	  static uchar
	  mgaread8(VGAscr* scr, int index)
	  {
	- 	return ((uchar*)scr->io)[index];
	+ 	return ((uchar*)scr->mmio)[index];
	  }
	  
	  static uchar
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:163,181 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:118,130
	  mga4xxenable(VGAscr* scr)
	  {
	  	Pcidev *	pci;
	- 	int 		size, align;
	- 	ulong 	aperture;
	+ 	int 		size;
	  	int 		i, n, k;
	  	uchar *	p;
	  	uchar	x[16];
	  	uchar	crtcext3;
	  
	- 	/*
	- 	 * Only once, can't be disabled for now.
	- 	 * scr->io holds the virtual address of
	- 	 * the MMIO registers.
	- 	 */
	- 	if(scr->io)
	+ 	if(scr->mmio)
	  		return;
	  
	  	pci = mgapcimatch();
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:182,222 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:131,170
	  	if(pci == nil)
	  		return;
	  
	- 	scr->io = upamalloc(pci->mem[1].bar & ~0x0F, 16*1024, 0);
	- 	if(scr->io == 0)
	+ 	scr->mmio = vmap(pci->mem[1].bar&~0x0F, 16*1024);
	+ 	if(scr->mmio == nil)
	  		return;
	+ 	
	+ 	addvgaseg("mga4xxmmio", pci->mem[1].bar&~0x0F, pci->mem[1].size);
	  
	- 	addvgaseg("mga4xxmmio", scr->io, pci->mem[1].size);
	- 
	- 	scr->io = (ulong)KADDR(scr->io);
	- 
	  	/* need to map frame buffer here too, so vga can find memory size */
	- 	size = 8*Meg;
	- 	align = 0;
	- 	aperture = mga4xxlinear(scr, &size, &align);
	- 	if(aperture) {
	- 		scr->aperture = aperture;
	- 		addvgaseg("mga4xxscreen", aperture, size);
	+ 	if(pci->did == MGA4xx)
	+ 		size = 32*MB;
	+ 	else
	+ 		size = 8*MB;
	+ 	vgalinearaddr(scr, pci->mem[0].bar&~0x0F, size);
	  
	- 		/* Find out how much memory is here, some multiple of 2 Meg */
	+ 	if(scr->paddr){
	  
	+ 		/* Find out how much memory is here, some multiple of 2 MB */
	+ 
	  		/* First Set MGA Mode ... */
	  		crtcext3 = crtcextset(scr, 3, 0x80, 0x00);
	  
	- 		p = (uchar*)aperture;
	- 		n = (size / Meg) / 2;
	+ 		p = scr->vaddr;
	+ 		n = (size / MB) / 2;
	  		for (i = 0; i < n; i++) {
	- 			k = (2*i+1)*Meg;
	+ 			k = (2*i+1)*MB;
	  			p[k] = 0;
	  			p[k] = i+1;
	- 			*((uchar*)(scr->io + CACHEFLUSH)) = 0;
	+ 			*((uchar*)scr->mmio + CACHEFLUSH) = 0;
	  			x[i] = p[k];
	   		}
	  		for(i = 1; i < n; i++)
	  			if(x[i] != i+1)
	  				break;
	-   		scr->apsize = 2*i*Meg;
	- 
	+ 		scr->apsize = 2*i*MB;	/* sketchy */
	+ 		addvgaseg("mga4xxscreen", scr->paddr, scr->apsize);
	  		crtcextset(scr, 3, crtcext3, 0xff);
	  	}
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:240,249 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:188,197
	  {
	  	uchar * 	dac4xx;
	  	
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	  
	- 	dac4xx = KADDR(scr->io+0x3C00);
	+ 	dac4xx = (uchar*)scr->mmio+0x3C00;
	  	
	  	*(dac4xx+Index) = Icctl;
	  	*(dac4xx+Data) = 0x00;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:256,269 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:204,217
	  	uchar *	p;
	  	uchar * 	dac4xx;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	  
	- 	dac4xx = KADDR(scr->io+0x3C00);
	+ 	dac4xx = (uchar*)scr->mmio+0x3C00;
	  	
	  	dac4xxdisable(scr);
	  
	- 	p = KADDR(scr->storage);
	+ 	p = scr->vaddr;
	  	for(y = 0; y < 64; y++){
	  		*p++ = 0; *p++ = 0; *p++ = 0;
	  		*p++ = 0; *p++ = 0; *p++ = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:296,305 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:244,253
	  	int 		x, y;
	  	uchar *	dac4xx;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return 1;
	  
	- 	dac4xx = KADDR(scr->io + 0x3C00);
	+ 	dac4xx = (uchar*)scr->mmio + 0x3C00;
	  
	  	x = p.x + scr->offset.x;
	  	y = p.y + scr->offset.y;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:319,327 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:267,275
	  	uchar *	dac4xx;
	  	ulong	storage;
	  	
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	dac4xx = KADDR(scr->io+0x3C00);
	+ 	dac4xx = (uchar*)scr->mmio+0x3C00;
	  
	  	dac4xxdisable(scr);
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:332,338 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:280,286
	  	*(dac4xx+Index) = Icuradrh;
	  	*(dac4xx+Data) = 0xff & (storage >> 18);		
	  
	- 	scr->storage = (ulong) KADDR((ulong)scr->aperture + (ulong)storage);
	+ 	scr->storage = (ulong)scr->vaddr + storage;
	  
	  	/* Show X11-Like Cursor */
	  	*(dac4xx+Index) = Icctl;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:380,388 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:328,336
	  	/* blank = 0 -> turn screen on */
	  	/* blank = 1 -> turn screen off */
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	mga = KADDR(scr->io);	
	+ 	mga = (uchar*)scr->mmio;	
	  
	  	if (blank == 0) {
	  		seq1 = 0x00;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:432,440 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:380,388
	  	uchar * 		mga;
	   
	  	/* Constant Shaded Trapezoids / Rectangle Fills */
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return 0;
	- 	mga = KADDR(scr->io);
	+ 	mga = (uchar*)scr->mmio;
	  
	  	mgawrite32(mga, DWGCTL, 0);
	  	mgawrite32(mga, FCOL, color);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:460,469 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:408,417
	  	int 		ydir;
	   
	  	/* Two-operand Bitblts */
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return 0;
	  
	- 	mga = KADDR(scr->io);
	+ 	mga = (uchar*)scr->mmio;
	  
	  	pitch = Dx(scr->gscreen->r);
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:556,564 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:504,512
	  	if (p == nil)
	  		return ;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	mga = KADDR(scr->io);
	+ 	mga = (uchar*)scr->mmio;
	  
	  	mgawrite32(mga, SRCORG, 0);
	  	mgawrite32(mga, DSTORG, 0);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgamga4xx.c:590,596 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgamga4xx.c:538,544
	  	mga4xxenable,		/* enable */
	  	0,					/* disable */
	  	0,					/* page */
	- 	mga4xxlinear,			/* linear */
	+ 	0,					/* linear */
	  	mga4xxdrawinit,
	  };
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 10143 Nov  6 10:23 sys/src/9/pc/vganeomagic.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:22,93 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:22,41
	  	int	addr;
	  };
	  
	- static ulong
	- neomagiclinear(VGAscr* scr, int* size, int* align)
	- {
	- 	ulong aperture, oaperture;
	- 	int oapsize, wasupamem;
	- 	Pcidev *p;
	- 
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	aperture = 0;
	- 	if(p = pcimatch(nil, 0x10C8, 0)){
	- 		switch(p->did){
	- 		case 0x0003:		/* MagicGraph 128ZV */
	- 		case 0x0083:		/* MagicGraph 128ZV+ */
	- 		case 0x0004:		/* MagicGraph 128XD */
	- 		case 0x0005:		/* MagicMedia 256AV */
	- 		case 0x0006:		/* MagicMedia 256ZX */
	- 			aperture = p->mem[0].bar & ~0x0F;
	- 			*size = p->mem[0].size;
	- 			break;
	- 		default:
	- 			break;
	- 		}
	- 	}
	- 
	- 	if(wasupamem){
	- 		if(oaperture == aperture)
	- 			return oaperture;
	- 		upafree(oaperture, oapsize);
	- 	}
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- //print("neomagiclinear1 %lux %d\n", aperture, *size);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0)){
	- 			aperture = oaperture;
	- 			scr->isupamem = 1;
	- 		}
	- 		else
	- 			scr->isupamem = 0;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	return aperture;
	- }
	- 
	  static void
	  neomagicenable(VGAscr* scr)
	  {
	  	Pcidev *p;
	- 	int align, curoff, size, vmsize;
	- 	ulong aperture;
	+ 	int curoff, vmsize;
	  	ulong ioaddr;
	  	ulong iosize;
	  
	  	/*
	- 	 * Only once, can't be disabled for now.
	- 	 * scr->io holds the physical address of the cursor registers
	+ 	 * scr->mmio holds the virtual address of the cursor registers
	  	 * in the MMIO space. This may need to change for older chips
	  	 * which have the MMIO space offset in the framebuffer region.
	  	 */
	- 	if(scr->io)
	+ 	if(scr->mmio)
	  		return;
	  	if(p = pcimatch(nil, 0x10C8, 0)){
	  		switch(p->did){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:127,137 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:75,86
	  	}
	  	else
	  		return;
	- 	scr->io = upamalloc(ioaddr, iosize, 0);
	- 	if(scr->io == 0)
	+ 	scr->pci = p;
	+ 
	+ 	scr->mmio = vmap(ioaddr, iosize);
	+ 	if(scr->mmio == nil)
	  		return;
	- 	addvgaseg("neomagicmmio", scr->io, iosize);
	- 	scr->mmio = KADDR(scr->io);
	+ 	addvgaseg("neomagicmmio", ioaddr, iosize);
	  
	  	/*
	  	 * Find a place for the cursor data in display memory.
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:139,154 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:88,97
	  	 * last 2KB of the framebuffer.
	  	 */
	  	scr->storage = vmsize-2*1024;
	- 	scr->io += curoff;
	- 
	- 	size = p->mem[0].size;
	- 	align = 0;
	- 	aperture = neomagiclinear(scr, &size, &align);
	- 	if(aperture) {
	- 		scr->aperture = aperture;
	- 		scr->apsize = size;
	- 		addvgaseg("neomagicscreen", aperture, size);
	- 	}
	+ 	scr->mmio = (ulong*)((uchar*)scr->mmio + curoff);
	+ 	vgalinearpci(scr);
	+ 	if(scr->paddr)
	+ 		addvgaseg("neomagicscreen", scr->paddr, scr->apsize);
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:156,164 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:99,107
	  {
	  	CursorNM *cursornm;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	cursornm = KADDR(scr->io);
	+ 	cursornm = (void*)scr->mmio;
	  	cursornm->enable = 0;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:169,175 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:112,118
	  	uint p0, p1;
	  	int x, y;
	  
	- 	p = KADDR(scr->aperture);
	+ 	p = (uchar*)scr->mmio;
	  	p += scr->storage + index*1024;
	  
	  	for(y = yo; y < 16; y++){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:211,219 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:154,162
	  {
	  	CursorNM *cursornm;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	cursornm = KADDR(scr->io);
	+ 	cursornm = (void*)scr->mmio;
	  
	  	cursornm->enable = 0;
	  	memmove(&scr->Cursor, curs, sizeof(Cursor));
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:227,235 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:170,178
	  	CursorNM *cursornm;
	  	int addr, index, x, xo, y, yo;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return 1;
	- 	cursornm = KADDR(scr->io);
	+ 	cursornm = (void*)scr->mmio;
	  
	  	index = 0;
	  	if((x = p.x+scr->offset.x) < 0){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:266,274 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:209,217
	  	CursorNM *cursornm;
	  
	  	neomagicenable(scr);
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	- 	cursornm = KADDR(scr->io);
	+ 	cursornm = (void*)scr->mmio;
	  	cursornm->enable = 0;
	  
	  	/*
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:426,432 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:369,375
	  		| NEO_BC0_SRC_IS_FG
	  		| NEO_BC3_SKIP_MAPPING
	  		| GXcopy;
	- 	mmio[DstStartOff] = scr->aperture
	+ 	mmio[DstStartOff] = scr->paddr
	  		+ r.min.y*scr->gscreen->width*BY2WD
	  		+ r.min.x*scr->gscreen->depth/BI2BY;
	  	mmio[XYExt] = (Dy(r) << 16) | (Dx(r) & 0xffff);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:452,460 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:395,403
	  			| NEO_BC3_FIFO_EN
	  			| NEO_BC3_SKIP_MAPPING
	  			| GXcopy;
	- 		mmio[SrcStartOff] = scr->aperture
	+ 		mmio[SrcStartOff] = scr->paddr
	  			+ sr.min.y*pitch + sr.min.x*pixel;
	- 		mmio[DstStartOff] = scr->aperture
	+ 		mmio[DstStartOff] = scr->paddr
	  			+ r.min.y*pitch + r.min.x*pixel;
	  	} else {
	  		/* start from lower-right */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:465,473 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:408,416
	  			| NEO_BC3_FIFO_EN
	  			| NEO_BC3_SKIP_MAPPING
	  			| GXcopy;
	- 		mmio[SrcStartOff] = scr->aperture
	+ 		mmio[SrcStartOff] = scr->paddr
	  			+ (sr.max.y-1)*pitch + (sr.max.x-1)*pixel;
	- 		mmio[DstStartOff] = scr->aperture
	+ 		mmio[DstStartOff] = scr->paddr
	  			+ (r.max.y-1)*pitch + (r.max.x-1)*pixel;
	  	}
	  	mmio[XYExt] = (Dy(r) << 16) | (Dx(r) & 0xffff);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganeomagic.c:549,555 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganeomagic.c:492,498
	  	neomagicenable,
	  	nil,
	  	nil,
	- 	neomagiclinear,
	+ 	nil,
	  	neomagicdrawinit,
	  };
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 11783 Nov  6 10:23 sys/src/9/pc/vganvidia.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:77,84 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:77,82
	  	int		dmamax;
	  } nv;
	  
	- 
	- /* Nvidia is good about backwards compatibility -- any did >= 0x20 is fine */
	  static Pcidev*
	  nvidiapci(void)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:92,134 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:90,98
	  	return nil;
	  }
	  
	- static ulong
	- nvidialinear(VGAscr* scr, int* size, int* align)
	+ static void
	+ nvidialinear(VGAscr*, int, int)
	  {
	- 	Pcidev *p;
	- 	int oapsize, wasupamem;
	- 	ulong aperture, oaperture;
	- 
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	aperture = 0;
	- 	if(p = nvidiapci()){
	- 		aperture = p->mem[1].bar & ~0x0F;
	- 		*size = p->mem[1].size;
	- 	}
	- 
	- 	if(wasupamem){
	- 		if(oaperture == aperture)
	- 			return oaperture;
	- 		upafree(oaperture, oapsize);
	- 	}
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0)){
	- 			aperture = oaperture;
	- 			scr->isupamem = 1;
	- 		}
	- 		else
	- 			scr->isupamem = 0;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	return aperture;
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:135,174 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:99,129
	  nvidiaenable(VGAscr* scr)
	  {
	  	Pcidev *p;
	- 	ulong aperture, *q;
	- 	int align, size, tmp;
	+ 	ulong *q;
	+ 	int tmp;
	  
	- 	/*
	- 	 * Only once, can't be disabled for now.
	- 	 * scr->io holds the physical address of
	- 	 * the MMIO registers.
	- 	 */
	- 	if(scr->io)
	+ 	if(scr->mmio)
	  		return;
	  	p = nvidiapci();
	  	if(p == nil)
	  		return;
	  	scr->id = p->did;
	+ 	scr->pci = p;
	  
	- 	scr->io = upamalloc(p->mem[0].bar & ~0x0F, p->mem[0].size, 0);
	- 	if(scr->io == 0)
	+ 	scr->mmio = vmap(p->mem[0].bar & ~0x0F, p->mem[0].size);
	+ 	if(scr->mmio == nil)
	  		return;
	- 	addvgaseg("nvidiammio", scr->io, p->mem[0].size);
	+ 	addvgaseg("nvidiammio", p->mem[0].bar&~0x0F, p->mem[0].size);
	  
	- 	size = p->mem[1].size;
	- 	align = 0;
	- 	aperture = nvidialinear(scr, &size, &align);
	- 	if(aperture){
	- 		scr->aperture = aperture;
	- 		scr->apsize = size;
	- 		addvgaseg("nvidiascreen", aperture, size);
	- 	}
	+ 	vgalinearpci(scr);
	+ 	if(scr->apsize)
	+ 		addvgaseg("nvidiascreen", scr->paddr, scr->apsize);
	  
	  	/* find video memory size */
	  	switch (scr->id & 0x0ff0) {
	  	case 0x0020:
	  	case 0x00A0:
	- 		q = KADDR(scr->io + Pfb);
	+ 		q = (void*)((uchar*)scr->mmio + Pfb);
	  		tmp = *q;
	  		if (tmp & 0x0100) {
	  			scr->storage = ((tmp >> 12) & 0x0F) * 1024 + 1024 * 2;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:191,197 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:146,152
	  		scr->storage = (((tmp >> 4) & 127) + 1) * 1024 * 1024;
	  		break;
	  	default:
	- 		q = KADDR(scr->io + Pfb +  0x020C);
	+ 		q = (void*)((uchar*)scr->mmio + Pfb +  0x020C);
	  		tmp = (*q >> 20) & 0xFF;
	  		if (tmp == 0)
	  			tmp = 16;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:203,209 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:158,164
	  static void
	  nvidiacurdisable(VGAscr* scr)
	  {
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	  
	  	vgaxo(Crtx, 0x31, vgaxi(Crtx, 0x31) & ~0x01);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:218,224 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:173,179
	  	ushort	c,s;
	  	ulong	tmp;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	  
	  	vgaxo(Crtx, 0x31, vgaxi(Crtx, 0x31) & ~0x01);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:226,235 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:181,190
	  	switch (scr->id & 0x0ff0) {
	  	case 0x0020:
	  	case 0x00A0:
	- 		p = KADDR(scr->io + Pramin + 0x1E00 * 4);
	+ 		p = (void*)((uchar*)scr->mmio + Pramin + 0x1E00 * 4);
	  		break;
	  	default:
	- 		p = KADDR(scr->aperture + scr->storage - 96*1024);
	+ 		p = (void*)((uchar*)scr->vaddr + scr->storage - 96*1024);
	  		break;
	  	}
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:268,277 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:223,232
	  {
	  	ulong*	cursorpos;
	  
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return 1;
	  
	- 	cursorpos = KADDR(scr->io + hwCurPos);
	+ 	cursorpos = (void*)((uchar*)scr->mmio + hwCurPos);
	  	*cursorpos = ((p.y+scr->offset.y)<<16)|((p.x+scr->offset.x) & 0xFFFF);
	  
	  	return 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:281,287 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:236,242
	  nvidiacurenable(VGAscr* scr)
	  {
	  	nvidiaenable(scr);
	- 	if(scr->io == 0)
	+ 	if(scr->mmio == 0)
	  		return;
	  
	  	vgaxo(Crtx, 0x1F, 0x57);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:299,307 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:254,262
	  	ulong	*fifo;
	  
	  	outb(0x3D0,0);
	- 	p=KADDR(scr->aperture);
	+ 	p = scr->vaddr;
	  	scratch = *p;
	- 	fifo = KADDR(scr->io + Fifo);
	+ 	fifo = (void*)((uchar*)scr->mmio + Fifo);
	  	fifo[0x10] = (data << 2);
	  	USED(scratch);
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:311,317 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:266,272
	  {
	  	ulong	*fifo;
	  
	- 	fifo = KADDR(scr->io + Fifo);
	+ 	fifo = (void*)((uchar*)scr->mmio + Fifo);
	  	return (fifo[0x0011] >> 2);
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:375,381 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:330,336
	  	ulong*	pgraph;
	  	int x;
	  
	- 	pgraph = KADDR(scr->io + Pgraph);
	+ 	pgraph = (void*)((uchar*)scr->mmio + Pgraph);
	  
	  	x = 0;
	  	while((readget(scr) != nv.dmaput) && x++ < 1000000)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:388,394 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:343,349
	  		;
	  
	  	if(x >= 1000000)
	- 		iprint("idle stat %lud scrio %.8lux scr %p pc %luX\n", *pgraph, scr->io, scr, getcallerpc(&scr));
	+ 		iprint("idle stat %lud scrio %.8lux scr %p pc %luX\n", *pgraph, scr->mmio, scr, getcallerpc(&scr));
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vganvidia.c:399,405 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vganvidia.c:354,360
	  
	  	pitch = scr->gscreen->width*BY2WD;
	  
	- 	nv.dmabase = KADDR(scr->aperture + scr->storage - 128*1024);
	+ 	nv.dmabase = (void*)((uchar*)scr->vaddr + scr->storage - 128*1024);
	  
	  	for(i=0; i<SKIPS; i++)
	  		nv.dmabase[i] = 0x00000000;
 [rsc] --rw-rw-r-- M 451989 glenda sys 4251 Nov  6 10:23 sys/src/9/pc/vgargb524.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgargb524.c:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgargb524.c:3,9
	  #include "mem.h"
	  #include "dat.h"
	  #include "fns.h"
	+ #include "io.h"
	  #include "../port/error.h"
	  
	  #define	Image	IMAGE
 [rsc] --rw-rw-r-- M 451989 glenda sys 10994 Nov  6 10:23 sys/src/9/pc/vgas3.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgas3.c:88,188 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgas3.c:88,136
	  	}
	  }
	  
	- static ulong
	- s3linear(VGAscr* scr, int* size, int* align)
	+ static void
	+ s3linear(VGAscr* scr, int, int)
	  {
	- 	char *mmioname;
	- 	ulong aperture, oaperture, mmiobase, mmiosize;
	- 	int i, id, j, osize, oapsize, wasupamem;
	+ 	int id, j;
	+ 	ulong mmiobase, mmiosize;
	  	Pcidev *p;
	- 
	- 	osize = *size;
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	mmiosize = 0;
	- 	mmiobase = 0;
	- 	mmioname = nil;
	- 
	- 	/*
	- 	 * S3 makes cards other than display controllers, so
	- 	 * look for the first S3 display controller (device class 3)
	- 	 * and not one of their sound cards.
	- 	 */
	- 	p = nil;
	- 	while(p = pcimatch(p, PCIS3, 0)){
	- 		if(p->ccrb == 0x03)
	- 			break;
	- 	}
	- 	if(p != nil){
	- 		for(i=0; i<nelem(p->mem); i++){
	- 			if(p->mem[i].size >= *size
	- 			&& ((p->mem[i].bar & ~0x0F) & (*align-1)) == 0)
	+ 	
	+ 	vgalinearpciid(scr, PCIS3, 0);
	+ 	p = scr->pci;
	+ 	if(scr->paddr == 0 || p == nil)
	+ 		return;
	+ 		
	+ 	addvgaseg("s3screen", scr->paddr, scr->apsize);
	+ 	
	+ 	id = (vgaxi(Crtx, 0x2D)<<8)|vgaxi(Crtx, 0x2E);
	+ 	switch(id){			/* find mmio */
	+ 	case SAVAGE4:
	+ 	case PROSAVAGEP:
	+ 	case PROSAVAGEK:
	+ 	case PROSAVAGE8:
	+ 	case SUPERSAVAGEIXC16:
	+ 		/*
	+ 		 * We could assume that the MMIO registers
	+ 		 * will be in the screen segment and just use
	+ 		 * that, but PCI software is allowed to move them
	+ 		 * if it feels like it, so we look for an aperture of
	+ 		 * the right size; only the first 512k actually means
	+ 		 * anything.  The S3 engineers overestimated how
	+ 		 * much space they would need in the first design.
	+ 		 */
	+ 		for(j=0; j<nelem(p->mem); j++){
	+ 			if((p->mem[j].bar&~0x0F) != scr->paddr)
	+ 			if(p->mem[j].size==512*1024 || p->mem[j].size==16*1024*1024){
	+ 				mmiobase = p->mem[j].bar & ~0x0F;
	+ 				mmiosize = 512*1024;
	+ 				scr->mmio = vmap(mmiobase, mmiosize);
	+ 				if(scr->mmio == nil)
	+ 					return;
	+ 				addvgaseg("savagemmio", mmiobase, mmiosize);
	  				break;
	- 		}
	- 		if(i >= nelem(p->mem)){
	- 			print("vgas3: aperture not found\n");
	- 			return 0;
	- 		}
	- 		aperture = p->mem[i].bar & ~0x0F;
	- 		*size = p->mem[i].size;
	- 
	- 		id = (vgaxi(Crtx, 0x2D)<<8)|vgaxi(Crtx, 0x2E);
	- 		switch(id){			/* find mmio */
	- 		case SAVAGE4:
	- 		case PROSAVAGEP:
	- 		case PROSAVAGEK:
	- 		case PROSAVAGE8:
	- 		case SUPERSAVAGEIXC16:
	- 			/*
	- 			 * We could assume that the MMIO registers
	- 			 * will be in the screen segment and just use
	- 			 * that, but PCI software is allowed to move them
	- 			 * if it feels like it, so we look for an aperture of
	- 			 * the right size; only the first 512k actually means
	- 			 * anything.  The S3 engineers overestimated how
	- 			 * much space they would need in the first design.
	- 			 */
	- 			for(j=0; j<nelem(p->mem); j++){
	- 				if(i == j)
	- 					continue;
	- 				if(p->mem[j].size==512*1024 || p->mem[j].size==16*1024*1024){
	- 					mmiobase = p->mem[j].bar & ~0x0F;
	- 					mmiosize = 512*1024;
	- 					scr->mmio = (ulong*)upamalloc(mmiobase, mmiosize, 0);
	- 					mmioname = "savagemmio";
	- 					break;
	- 				}
	  			}
	- 			if(mmiosize == 0){
	- 				print("savage4: mmio not found\n");
	- 				return 0;
	- 			}
	  		}
	- 	}else
	- 		aperture = 0;
	- 
	- 	if(wasupamem)
	- 		upafree(oaperture, oapsize);
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0))
	- 			scr->isupamem = 1;
	  	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	if(oaperture && oaperture != aperture)
	- 		print("warning (BUG): redefinition of aperture does not change s3screen segment\n");
	- 	addvgaseg("s3screen", aperture, osize);
	- 
	- 	if(mmiosize)
	- 		addvgaseg(mmioname, mmiobase, mmiosize);
	- 
	- 	return aperture;
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgas3.c:223,229 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgas3.c:171,177
	  	s3disable(scr);
	  
	  	opage = 0;
	- 	p = KADDR(scr->aperture);
	+ 	p = scr->vaddr;
	  	id = (vgaxi(Crtx, 0x2D)<<8)|vgaxi(Crtx, 0x2E);
	  	switch(id){
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgas3.c:498,505 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgas3.c:446,453
	  	mmio = scr->mmio;
	  	waitforlinearfifo(scr);
	  	waitforfifo(scr, 7);
	- 	mmio[SrcBase] = scr->aperture;
	- 	mmio[DstBase] = scr->aperture;
	+ 	mmio[SrcBase] = scr->paddr;
	+ 	mmio[DstBase] = scr->paddr;
	  	mmio[Stride] = (stride<<16)|stride;
	  	mmio[WidthHeight] = ((Dx(r)-1)<<16)|Dy(r);
	  	mmio[SrcXY] = (sp.x<<16)|sp.y;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgas3.c:524,532 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgas3.c:472,480
	  	mmio = scr->mmio;
	  	waitforlinearfifo(scr);
	  	waitforfifo(scr, 8);
	- 	mmio[SrcBase] = scr->aperture;
	- 	mmio[DstBase] = scr->aperture;
	- 	mmio[DstBase] = scr->aperture;
	+ 	mmio[SrcBase] = scr->paddr;
	+ 	mmio[DstBase] = scr->paddr;
	+ 	mmio[DstBase] = scr->paddr;
	  	mmio[Stride] = (stride<<16)|stride;
	  	mmio[FgrdData] = sval;
	  	mmio[WidthHeight] = ((Dx(r)-1)<<16)|Dy(r);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgas3.c:579,591 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgas3.c:527,539
	  	case VIRGE:
	  	case VIRGEVX:
	  	case VIRGEGX2:
	- 		scr->mmio = (ulong*)(scr->aperture+0x1000000);
	+ 		scr->mmio = (ulong*)((char*)scr->vaddr+0x1000000);
	  		scr->fill = hwfill;
	  		scr->scroll = hwscroll;
	  		break;
	  	case SAVAGEMXMV:
	  	case SAVAGEIXMV:
	- 		scr->mmio = (ulong*)(scr->aperture+0x1000000);
	+ 		scr->mmio = (ulong*)((char*)scr->vaddr+0x1000000);
	  		savageinit(scr);	
	  		break;
	  	case SUPERSAVAGEIXC16:
 [rsc] --rw-rw-r-- M 451989 glenda sys 9351 Nov  6 10:23 sys/src/9/pc/vgat2r4.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgat2r4.c:56,118 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgat2r4.c:56,67
	  	CursorMode	= CursorMode32x32,
	  };
	  
	- static ulong
	- t2r4linear(VGAscr* scr, int* size, int* align)
	- {
	- 	ulong aperture, oaperture;
	- 	int oapsize, wasupamem;
	- 	Pcidev *p;
	- 
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	- 	aperture = 0;
	- 	if(p = pcimatch(nil, 0x105D, 0)){
	- 		switch(p->did){
	- 		case 0x5348:
	- 			aperture = p->mem[0].bar & ~0x0F;
	- 			*size = p->mem[0].size;
	- 			break;
	- 		default:
	- 			break;
	- 		}
	- 	}
	- 
	- 	if(wasupamem){
	- 		if(oaperture == aperture)
	- 			return oaperture;
	- 		upafree(oaperture, oapsize);
	- 	}
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0)){
	- 			aperture = oaperture;
	- 			scr->isupamem = 1;
	- 		}
	- 		else
	- 			scr->isupamem = 0;
	- 	}
	- 	else
	- 		scr->isupamem = 1;
	- 
	- 	return aperture;
	- }
	- 
	  static void
	  t2r4enable(VGAscr* scr)
	  {
	  	Pcidev *p;
	- 	int size, align;
	- 	ulong aperture, mmio;
	+ 	void *mmio;
	  
	- 	/*
	- 	 * Only once, can't be disabled for now.
	- 	 * scr->mmio holds the virtual address of
	- 	 * the MMIO registers.
	- 	 */
	  	if(scr->mmio)
	  		return;
	  	if(p = pcimatch(nil, 0x105D, 0)){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgat2r4.c:125,145 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgat2r4.c:74,90
	  	}
	  	else
	  		return;
	- 	mmio = upamalloc(p->mem[4].bar & ~0x0F, p->mem[4].size, 0);
	- 	if(mmio == 0)
	+ 	scr->pci = p;
	+ 	
	+ 	mmio = vmap(p->mem[4].bar & ~0x0F, p->mem[4].size);
	+ 	if(mmio == nil)
	  		return;
	- 	addvgaseg("t2r4mmio", mmio, p->mem[4].size);
	+ 	addvgaseg("t2r4mmio", p->mem[4].bar & ~0x0F, p->mem[4].size);
	  
	- 	scr->mmio = KADDR(mmio);
	- 
	- 	size = p->mem[0].size;
	- 	align = 0;
	- 	aperture = t2r4linear(scr, &size, &align);
	- 	if(aperture){
	- 		scr->aperture = aperture;
	- 		scr->apsize = size;
	- 		addvgaseg("t2r4screen", aperture, size);
	- 	}
	+ 	scr->mmio = mmio;
	+ 	vgalinearpci(scr);
	+ 	if(scr->paddr)
	+ 		addvgaseg("t2r4screen", scr->paddr, scr->apsize);
	  }
	  
	  static uchar
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgat2r4.c:571,577 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgat2r4.c:516,522
	  	t2r4enable,
	  	nil,
	  	nil,
	- 	t2r4linear,
	+ 	nil,
	  	t2r4drawinit,
	  };
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 4507 Nov  6 10:23 sys/src/9/pc/vgatvp3020.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgatvp3020.c:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgatvp3020.c:3,9
	  #include "mem.h"
	  #include "dat.h"
	  #include "fns.h"
	+ #include "io.h"
	  #include "../port/error.h"
	  
	  #define	Image	IMAGE
 [rsc] --rw-rw-r-- M 451989 glenda sys 3956 Nov  6 10:23 sys/src/9/pc/vgatvp3026.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgatvp3026.c:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgatvp3026.c:3,9
	  #include "mem.h"
	  #include "dat.h"
	  #include "fns.h"
	+ #include "io.h"
	  #include "../port/error.h"
	  
	  #define	Image	IMAGE
 [rsc] --rw-rw-r-- M 451989 glenda sys 5840 Nov  6 10:23 sys/src/9/pc/vgavmware.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgavmware.c:144,162 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgavmware.c:144,155
	  		;
	  }
	  
	- static ulong
	- vmwarelinear(VGAscr* scr, int* size, int* align)
	+ static void
	+ vmwarelinear(VGAscr* scr, int, int)
	  {
	  	char err[64];
	- 	ulong aperture, oaperture;
	- 	int osize, oapsize, wasupamem;
	  	Pcidev *p;
	  
	- 	osize = *size;
	- 	oaperture = scr->aperture;
	- 	oapsize = scr->apsize;
	- 	wasupamem = scr->isupamem;
	- 
	  	p = pcimatch(nil, PCIVMWARE, 0);
	  	if(p == nil)
	  		error("no vmware card found");
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgavmware.c:176,200 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgavmware.c:169,177
	  		vm->rd = vm->ra + 1;
	  	}
	  
	- 	aperture = (ulong)(vmrd(vm, Rfbstart));
	- 	*size = vmrd(vm, Rfbsize);
	- 
	- 	if(wasupamem)
	- 		upafree(oaperture, oapsize);
	- 	scr->isupamem = 0;
	- 
	- 	aperture = upamalloc(aperture, *size, *align);
	- 	if(aperture == 0){
	- 		if(wasupamem && upamalloc(oaperture, oapsize, 0))
	- 			scr->isupamem = 1;
	- 	}else
	- 		scr->isupamem = 1;
	- 
	- 	if(oaperture && aperture != oaperture)
	- 		print("warning (BUG): redefinition of aperture does not change vmwarescreen segment\n");
	- 	addvgaseg("vmwarescreen", aperture, osize);
	- 
	- 	return aperture;
	+ 	vgalinearaddr(scr, vmrd(vm, Rfbstart), vmrd(vm, Rfbsize));
	+ 	if(scr->apsize)
	+ 		addvgaseg("vmwarescreen", scr->paddr, scr->apsize);
	  }
	  
	  static void
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgavmware.c:341,351 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgavmware.c:318,328
	  		if(mmiobase == 0)
	  			return;
	  		mmiosize = vmrd(vm, Rmemsize);
	- 		scr->mmio = KADDR(upamalloc(mmiobase, mmiosize, 0));
	- 		vm->mmio = scr->mmio;
	- 		vm->mmiosize = mmiosize;
	+ 		scr->mmio = vmap(mmiobase, mmiosize);
	  		if(scr->mmio == nil)
	  			return;
	+ 		vm->mmio = scr->mmio;
	+ 		vm->mmiosize = mmiosize;
	  		addvgaseg("vmwaremmio", mmiobase, mmiosize);
	  	}
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 1671 Nov  6 10:23 sys/src/9/pc/vgax.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/vgax.c:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/vgax.c:3,9
	  #include "mem.h"
	  #include "dat.h"
	  #include "fns.h"
	+ #include "io.h"
	  #include "../port/error.h"
	  
	  #define	Image	IMAGE
 [rsc] --rw-rw-r-- M 451989 glenda sys 8219 Nov  6 10:11 sys/src/9/port/dev.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/dev.c:157,163 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/dev.c:157,162
	  	nc->qid = c->qid;
	  	nc->offset = c->offset;
	  	nc->umh = nil;
	- 	nc->mountid = c->mountid;
	  	nc->aux = c->aux;
	  	nc->mqid = c->mqid;
	  	nc->mcp = c->mcp;
 [rsc] --rw-rw-r-- M 451989 glenda sys 43537 Nov  6 10:11 sys/src/9/port/devdraw.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:16,21 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:16,22
	  {
	  	Qtopdir		= 0,
	  	Qnew,
	+ 	Qwinname,
	  	Q3rd,
	  	Q2nd,
	  	Qcolormap,
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:53,59 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:54,59
	  
	  struct Draw
	  {
	- 	QLock;
	  	int		clientid;
	  	int		nclient;
	  	Client**	client;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:154,161 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:154,166
	  };
	  
	  static	Draw		sdraw;
	+ 	QLock	drawlock;
	+ 
	  static	Memimage	*screenimage;
	- static	Memdata		screendata;
	+ static	DImage*	screendimage;
	+ static	char	screenname[40];
	+ static	int	screennameid;
	+ 
	  static	Rectangle	flushrect;
	  static	int		waste;
	  static	DScreen*	dscreen;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:164,169 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:169,175
	  	void		drawuninstall(Client*, int);
	  	void		drawfreedimage(DImage*);
	  	Client*		drawclientofpath(ulong);
	+ 	DImage*	allocdimage(Memimage*);
	  
	  static	char Enodrawimage[] =	"unknown id for draw image";
	  static	char Enodrawscreen[] =	"unknown id for draw screen";
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:184,190 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:190,214
	  static	char Enamed[] = 	"image already has name";
	  static	char Ewrongname[] = 	"wrong name for image";
	  
	+ static void
	+ dlock(void)
	+ {
	+ 	qlock(&drawlock);
	+ }
	+ 
	  static int
	+ candlock(void)
	+ {
	+ 	return canqlock(&drawlock);
	+ }
	+ 
	+ static void
	+ dunlock(void)
	+ {
	+ 	qunlock(&drawlock);
	+ }
	+ 
	+ static int
	  drawgen(Chan *c, char*, Dirtab*, int, int s, Dir *dp)
	  {
	  	int t;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:226,231 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:250,259
	  			mkqid(&q, Q2nd, 0, QTDIR);
	  			devdir(c, q, "draw", 0, eve, 0555, dp);
	  			break;
	+ 		case 1:
	+ 			mkqid(&q, Qwinname, 0, 0);
	+ 			devdir(c, q, "winname", 0, eve, 0444, dp);
	+ 			break;
	  		default:
	  			return -1;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:498,505 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:526,533
	  	return 0;
	  }
	  
	- Memimage*
	- drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)
	+ DImage*
	+ allocdimage(Memimage *i)
	  {
	  	DImage *d;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:506,512 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:534,539
	  	d = malloc(sizeof(DImage));
	  	if(d == 0)
	  		return 0;
	- 	d->id = id;
	  	d->ref = 1;
	  	d->name = 0;
	  	d->vers = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:514,519 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:541,558
	  	d->nfchar = 0;
	  	d->fchar = 0;
	  	d->fromname = 0;
	+ 	return d;
	+ }
	+ 
	+ Memimage*
	+ drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)
	+ {
	+ 	DImage *d;
	+ 
	+ 	d = allocdimage(i);
	+ 	if(d == 0)
	+ 		return 0;
	+ 	d->id = id;
	  	d->dscreen = dscreen;
	  	d->next = client->dimage[id&HASHMASK];
	  	client->dimage[id&HASHMASK] = d;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:637,644 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:676,683
	  		drawfreedimage(dimage->fromname);
	  		goto Return;
	  	}
	- 	if(dimage->image == screenimage)	/* don't free the display */
	- 		goto Return;
	+ //	if(dimage->image == screenimage)	/* don't free the display */
	+ //		goto Return;
	  	ds = dimage->dscreen;
	  	if(ds){
	  		l = dimage->image;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:856,885 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:895,954
	  	return p;
	  }
	  
	- static int
	- initscreenimage(void)
	+ static DImage*
	+ makescreenimage(void)
	  {
	  	int width, depth;
	  	ulong chan;
	+ 	DImage *di;
	+ 	Memdata *md;
	+ 	Memimage *i;
	  	Rectangle r;
	  
	+ 	md = malloc(sizeof *md);
	+ 	if(md == nil)
	+ 		return nil;
	+ 	md->allocd = 1;
	+ 	md->base = nil;
	+ 	md->bdata = attachscreen(&r, &chan, &depth, &width, &sdraw.softscreen);
	+ 	if(md->bdata == nil){
	+ 		free(md);
	+ 		return nil;
	+ 	}
	+ 	md->ref = 1;
	+ 	i = allocmemimaged(r, chan, md);
	+ 	if(i == nil){
	+ 		free(md);
	+ 		return nil;
	+ 	}
	+ 	i->width = width;
	+ 	i->clipr = r;
	+ 
	+ 	di = allocdimage(i);
	+ 	if(di == nil){
	+ 		freememimage(i);	/* frees md */
	+ 		return nil;
	+ 	}
	+ 	if(!waserror()){
	+ 		snprint(screenname, sizeof screenname, "noborder.screen.%d", ++screennameid);
	+ 		drawaddname(nil, di, strlen(screenname), screenname);
	+ 		poperror();
	+ 	}
	+ 	return di;
	+ }
	+ 
	+ static int
	+ initscreenimage(void)
	+ {
	  	if(screenimage != nil)
	  		return 1;
	  
	- 	screendata.base = nil;
	- 	screendata.bdata = attachscreen(&r, &chan, &depth, &width, &sdraw.softscreen);
	- 	if(screendata.bdata == nil)
	+ 	screendimage = makescreenimage();
	+ 	if(screendimage == nil)
	  		return 0;
	- 	screendata.ref = 1;
	- 
	- 	screenimage = allocmemimaged(r, chan, &screendata);
	- 	if(screenimage == nil){
	- 		/* RSC: BUG: detach screen */
	- 		return 0;
	- 	}
	- 
	- 	screenimage->width = width;
	- 	screenimage->clipr = r;
	+ 	screenimage = screendimage->image;
	+ // iprint("initscreenimage %p %p\n", screendimage, screenimage);
	+ 	mouseresize();
	  	return 1;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:886,908 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:955,990
	  void
	  deletescreenimage(void)
	  {
	- 	qlock(&sdraw);
	- 	/* RSC: BUG: detach screen */
	- 	if(screenimage)
	- 		freememimage(screenimage);
	- 	screenimage = nil;
	- 	qunlock(&sdraw);
	+ 	dlock();
	+ 	if(screenimage){
	+ 		/* will be freed via screendimage; disable */
	+ 		screenimage->clipr = ZR;
	+ 		screenimage = nil;
	+ 	}
	+ 	if(screendimage){
	+ 		drawfreedimage(screendimage);
	+ 		screendimage = nil;
	+ 	}
	+ 	dunlock();
	  }
	  
	+ void
	+ resetscreenimage(void)
	+ {
	+ 	dlock();
	+ 	initscreenimage();
	+ 	dunlock();
	+ }
	+ 
	  static Chan*
	  drawattach(char *spec)
	  {
	- 	qlock(&sdraw);
	+ 	dlock();
	  	if(!initscreenimage()){
	- 		qunlock(&sdraw);
	+ 		dunlock();
	  		error("no frame buffer");
	  	}
	- 	qunlock(&sdraw);
	+ 	dunlock();
	  	return devattach('i', spec);
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:909,915 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:991,997
	  static Walkqid*
	  drawwalk(Chan *c, Chan *nc, char **name, int nname)
	  {
	- 	if(screendata.bdata == nil)
	+ 	if(screenimage == nil)
	  		error("no frame buffer");
	  	return devwalk(c, nc, name, nname, 0, 0, drawgen);
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:924,929 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1006,1013
	  drawopen(Chan *c, int omode)
	  {
	  	Client *cl;
	+ 	DName *dn;
	+ 	DImage *di;
	  
	  	if(c->qid.type & QTDIR){
	  		c = devopen(c, omode, 0, 0, drawgen);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:930,938 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1014,1022
	  		c->iounit = IOUNIT;
	  	}
	  
	- 	qlock(&sdraw);
	+ 	dlock();
	  	if(waserror()){
	- 		qunlock(&sdraw);
	+ 		dunlock();
	  		nexterror();
	  	}
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:944,949 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1028,1036
	  	}
	  
	  	switch(QID(c->qid)){
	+ 	case Qwinname:
	+ 		break;
	+ 
	  	case Qnew:
	  		break;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:953,961 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1040,1061
	  			error(Einuse);
	  		cl->busy = 1;
	  		flushrect = Rect(10000, 10000, -10000, -10000);
	- 		drawinstall(cl, 0, screenimage, 0);
	+ 		dn = drawlookupname(strlen(screenname), screenname);
	+ 		if(dn == 0)
	+ 			error("draw: cannot happen 2");
	+ 		if(drawinstall(cl, 0, dn->dimage->image, 0) == 0)
	+ 			error(Edrawmem);
	+ 		di = drawlookup(cl, 0, 0);
	+ 		if(di == 0)
	+ 			error("draw: cannot happen 1");
	+ 		di->vers = dn->vers;
	+ 		di->name = smalloc(strlen(screenname)+1);
	+ 		strcpy(di->name, screenname);
	+ 		di->fromname = dn->dimage;
	+ 		di->fromname->ref++;
	  		incref(&cl->r);
	  		break;
	+ 
	  	case Qcolormap:
	  	case Qdata:
	  	case Qrefresh:
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:963,969 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1063,1069
	  		incref(&cl->r);
	  		break;
	  	}
	- 	qunlock(&sdraw);
	+ 	dunlock();
	  	poperror();
	  	c->mode = openmode(omode);
	  	c->flag |= COPEN;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:982,990 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1082,1090
	  
	  	if(QID(c->qid) < Qcolormap)	/* Qtopdir, Qnew, Q3rd, Q2nd have no client */
	  		return;
	- 	qlock(&sdraw);
	+ 	dlock();
	  	if(waserror()){
	- 		qunlock(&sdraw);
	+ 		dunlock();
	  		nexterror();
	  	}
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:1017,1023 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1117,1123
	  		drawflush();	/* to erase visible, now dead windows */
	  		free(cl);
	  	}
	- 	qunlock(&sdraw);
	+ 	dunlock();
	  	poperror();
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:1036,1045 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1136,1148
	  
	  	if(c->qid.type & QTDIR)
	  		return devdirread(c, a, n, 0, 0, drawgen);
	+ 	if(QID(c->qid) == Qwinname)
	+ 		return readstr(off, a, n, screenname);
	+ 
	  	cl = drawclient(c);
	- 	qlock(&sdraw);
	+ 	dlock();
	  	if(waserror()){
	- 		qunlock(&sdraw);
	+ 		dunlock();
	  		nexterror();
	  	}
	  	switch(QID(c->qid)){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:1096,1109 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1199,1212
	  		for(;;){
	  			if(cl->refreshme || cl->refresh)
	  				break;
	- 			qunlock(&sdraw);
	+ 			dunlock();
	  			if(waserror()){
	- 				qlock(&sdraw);	/* restore lock for waserror() above */
	+ 				dlock();	/* restore lock for waserror() above */
	  				nexterror();
	  			}
	  			sleep(&cl->refrend, drawrefactive, cl);
	  			poperror();
	- 			qlock(&sdraw);
	+ 			dlock();
	  		}
	  		p = a;
	  		while(cl->refresh && n>=5*4){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:1120,1127 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1223,1231
	  		}
	  		cl->refreshme = 0;
	  		n = p-(uchar*)a;
	+ 		break;
	  	}
	- 	qunlock(&sdraw);
	+ 	dunlock();
	  	poperror();
	  	return n;
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:1149,1158 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1253,1262
	  	if(c->qid.type & QTDIR)
	  		error(Eisdir);
	  	cl = drawclient(c);
	- 	qlock(&sdraw);
	+ 	dlock();
	  	if(waserror()){
	  		drawwakeall();
	- 		qunlock(&sdraw);
	+ 		dunlock();
	  		nexterror();
	  	}
	  	switch(QID(c->qid)){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:1206,1212 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:1310,1316
	  	default:
	  		error(Ebadusefd);
	  	}
	- 	qunlock(&sdraw);
	+ 	dunlock();
	  	poperror();
	  	return n;
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:2022,2031 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:2126,2135
	  
	  	if(blank == sdraw.blanked)
	  		return;
	- 	if(!canqlock(&sdraw))
	+ 	if(!candlock())
	  		return;
	  	if(!initscreenimage()){
	- 		qunlock(&sdraw);
	+ 		dunlock();
	  		return;
	  	}
	  	p = sdraw.savemap;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devdraw.c:2048,2054 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devdraw.c:2152,2158
	  		}
	  	}
	  	sdraw.blanked = blank;
	- 	qunlock(&sdraw);
	+ 	dunlock();
	  }
	  
	  /*
 [rsc] --rw-rw-r-- M 451989 glenda sys 28233 Nov  6 10:11 sys/src/9/port/devproc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devproc.c:669,686 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devproc.c:669,688
	  static long
	  procread(Chan *c, void *va, long n, vlong off)
	  {
	- 	int m, navail, ne;
	+ 	char *a, flag[10], *sps, *srv, statbuf[NSEG*32];
	+ 	int i, j, m, navail, ne, pid, rsize;
	  	long l;
	- 	Proc *p;
	- 	Waitq *wq;
	- 	Ureg kur;
	  	uchar *rptr;
	+ 	ulong offset;
	+ 	Confmem *cm;
	  	Mntwalk *mw;
	+ 	Proc *p;
	  	Segment *sg, *s;
	- 	char *a = va, *sps;
	- 	int i, j, rsize, pid;
	- 	char statbuf[NSEG*32], *srv, flag[10];
	- 	ulong offset = off;
	+ 	Ureg kur;
	+ 	Waitq *wq;
	+ 	
	+ 	a = va;
	+ 	offset = off;
	  
	  	if(c->qid.type & QTDIR)
	  		return devdirread(c, a, n, 0, 0, procgen);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devproc.c:723,730 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devproc.c:725,731
	  		return n;
	  
	  	case Qmem:
	- 		if(offset < KZERO
	- 		|| (offset >= USTKTOP-USTKSIZE && offset < USTKTOP))
	+ 		if(offset < KZERO)
	  			return procctlmemio(p, offset, n, va, 1);
	  
	  		if(!iseve())
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devproc.c:737,754 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devproc.c:738,751
	  			memmove(a, (char*)offset, n);
	  			return n;
	  		}
	- 		/* conf.base* and conf.npage* are set by xinit to refer to kernel allocation, not user pages */
	- 		if(offset >= conf.base0 && offset < conf.npage0){
	- 			if(offset+n > conf.npage0)
	- 				n = conf.npage0 - offset;
	- 			memmove(a, (char*)offset, n);
	- 			return n;
	- 		}
	- 		if(offset >= conf.base1 && offset < conf.npage1){
	- 			if(offset+n > conf.npage1)
	- 				n = conf.npage1 - offset;
	- 			memmove(a, (char*)offset, n);
	- 			return n;
	+ 		for(i=0; i<nelem(conf.mem); i++){
	+ 			cm = &conf.mem[i];
	+ 			if(cm->kbase <= offset && offset < cm->klimit){
	+ 				if(offset+n > cm->klimit)
	+ 					n = cm->klimit - offset;
	+ 				memmove(a, (char*)offset, n);
	+ 				return n;
	+ 			}
	  		}
	  		error(Ebadarg);
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 30798 Nov  6 10:11 sys/src/9/port/devsd.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:15,29 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:15,29
	  extern Dev sddevtab;
	  extern SDifc* sdifc[];
	  
	- typedef struct SDevgrp {
	- 	SDev*	dev;
	- 	int	nunits;		/* num units in dev */
	- } SDevgrp;
	+ static char Echange[] = "media or partition has changed";
	  
	- static SDevgrp* devs;			/* all devices */
	- static QLock devslock;			/* insertion and removal of devices */
	- static int ndevs;			/* total number of devices in the system */
	+ static char devletters[] = "0123456789"
	+ 	"abcdefghijklmnopqrstuvwxyz"
	+ 	"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	  
	+ static SDev *devs[sizeof devletters-1];
	+ static QLock devslock;
	+ 
	  enum {
	  	Rawcmd,
	  	Rawdata,
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:33,40 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:33,39
	  enum {
	  	Qtopdir		= 1,		/* top level directory */
	  	Qtopbase,
	- 	Qtopctl = Qtopbase,
	- 	Qtopstat,
	+ 	Qtopctl		 = Qtopbase,
	  
	  	Qunitdir,			/* directory per unit */
	  	Qunitbase,
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:59,66 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:58,65
	  
	  	DevLOG		= 8,
	  	NDev		= (1 << DevLOG),
	- 	DevMASK	= (NDev-1),
	- 	DevSHIFT = (UnitLOG+PartLOG+TypeLOG),
	+ 	DevMASK		= (NDev-1),
	+ 	DevSHIFT	 = (UnitLOG+PartLOG+TypeLOG),
	  
	  	Ncmd = 20,
	  };
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:221,226 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:220,236
	  	return 1;
	  }
	  
	+ static int
	+ sdindex(int idno)
	+ {
	+ 	char *p;
	+ 	
	+ 	p = strchr(devletters, idno);
	+ 	if(p == nil)
	+ 		return -1;
	+ 	return p-devletters;
	+ }
	+ 
	  static SDev*
	  sdgetdev(int idno)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:227,243 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:237,248
	  	SDev *sdev;
	  	int i;
	  
	+ 	if((i = sdindex(idno)) < 0)
	+ 		return nil;
	+ 
	  	qlock(&devslock);
	- 	for(i = 0; i != ndevs; i++)
	- 		if(devs[i].dev->idno == idno)
	- 			break;
	- 	
	- 	if(i == ndevs)
	- 		sdev = nil;
	- 	else{
	- 		sdev = devs[i].dev;
	+ 	if(sdev = devs[i])
	  		incref(&sdev->r);
	- 	}
	  	qunlock(&devslock);
	  	return sdev;
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:307,374 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:312,370
	  sdreset(void)
	  {
	  	int i;
	- 	SDev *sdev, *tail, *sdlist;
	+ 	SDev *sdev;
	  
	  	/*
	- 	 * Probe all configured controllers and make a list
	- 	 * of devices found, accumulating a possible maximum number
	- 	 * of units attached and marking each device with an index
	- 	 * into the linear top-level directory array of units.
	+ 	 * Probe all known controller types and register any devices found.
	  	 */
	- 	tail = sdlist = nil;
	  	for(i = 0; sdifc[i] != nil; i++){
	  		if(sdifc[i]->pnp == nil || (sdev = sdifc[i]->pnp()) == nil)
	  			continue;
	- 		if(sdlist != nil)
	- 			tail->next = sdev;
	- 		else
	- 			sdlist = sdev;
	- 		for(tail = sdev; tail->next != nil; tail = tail->next){
	- 			tail->unit = (SDunit**)malloc(tail->nunit * sizeof(SDunit*));
	- 			tail->unitflg = (int*)malloc(tail->nunit * sizeof(int));
	- 			assert(tail->unit && tail->unitflg);
	- 			ndevs++;
	- 		}
	- 		tail->unit = (SDunit**)malloc(tail->nunit * sizeof(SDunit*));
	- 		tail->unitflg = (int*)malloc(tail->nunit * sizeof(int));
	- 		ndevs++;
	+ 		sdadddevs(sdev);
	  	}
	- 	
	- 	/*
	- 	 * Legacy and option code goes here. This will be hard...
	- 	 */
	+ }
	  
	- 	/*
	- 	 * The maximum number of possible units is known, allocate
	- 	 * placeholders for their datastructures; the units will be
	- 	 * probed and structures allocated when attached.
	- 	 * Allocate controller names for the different types.
	- 	 */
	- 	if(ndevs == 0)
	- 		return;
	- 	for(i = 0; sdifc[i] != nil; i++){
	- 		/*
	- 		 * BUG: no check is made here or later when a
	- 		 * unit is attached that the id and name are set.
	- 		 */
	- 		if(sdifc[i]->id)
	- 			sdifc[i]->id(sdlist);
	+ void
	+ sdadddevs(SDev *sdev)
	+ {
	+ 	int i, j, id;
	+ 	SDev *next;
	+ 	
	+ 	for(; sdev; sdev=next){
	+ 		next = sdev->next;
	+ 		
	+ 		sdev->unit = (SDunit**)malloc(sdev->nunit * sizeof(SDunit*));
	+ 		sdev->unitflg = (int*)malloc(sdev->nunit * sizeof(int));
	+ 		if(sdev->unit == nil || sdev->unitflg == nil){
	+ 			print("sdadddevs: out of memory\n");
	+ 		giveup:
	+ 			free(sdev->unit);
	+ 			free(sdev->unitflg);
	+ 			if(sdev->ifc->clear)
	+ 				sdev->ifc->clear(sdev);
	+ 			free(sdev);
	+ 			continue;
	+ 		}
	+ 		id = sdindex(sdev->idno);
	+ 		if(id == -1){
	+ 			print("sdadddevs: bad id number %d (%C)\n", id, id);
	+ 			goto giveup;
	+ 		}
	+ 		qlock(&devslock);
	+ 		for(i=0; i<nelem(devs); i++){
	+ 			if(devs[j = (id+i)%nelem(devs)] == nil){
	+ 				sdev->idno = devletters[j];
	+ 				devs[j] = sdev;
	+ 				snprint(sdev->name, sizeof sdev->name, "sd%c", devletters[j]);
	+ 				break;
	+ 			}
	+ 		}
	+ 		qunlock(&devslock);
	+ 		if(i == nelem(devs)){
	+ 			print("sdadddevs: out of device letters\n");
	+ 			goto giveup;
	+ 		}
	  	}
	- 
	- 	/* 
	- 	  * The IDs have been set, unlink the sdlist and copy the spec to
	- 	  * the devtab.
	- 	  */
	- 	devs = (SDevgrp*)malloc(ndevs * sizeof(SDevgrp));
	- 	memset(devs, 0, ndevs * sizeof(SDevgrp));
	- 	i = 0;
	- 	while(sdlist != nil){
	- 		devs[i].dev = sdlist;
	- 		devs[i].nunits = sdlist->nunit;
	- 		sdlist = sdlist->next;
	- 		devs[i].dev->next = nil;
	- 		i++;
	- 	}
	  }
	  
	  static int
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:438,447 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:434,439
	  		mkqid(&q, QID(0, 0, 0, Qtopctl), 0, QTFILE);
	  		devdir(c, q, "sdctl", 0, eve, 0640, dp);
	  		return 1;
	- 	case Qtopstat:
	- 		mkqid(&q, QID(0, 0, 0, Qtopstat), 0, QTFILE);
	- 		devdir(c, q, "sdstat", 0, eve, 0640, dp);
	- 		return 1;
	  	}
	  	return -1;
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:465,488 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:457,482
	  			return 1;
	  		}
	  
	- 		if(s == 0 || s == 1)
	- 			return sd1gen(c, s + Qtopbase, dp);
	- 		s -= 2;
	+ 		if(s+Qtopbase < Qunitdir)
	+ 			return sd1gen(c, s+Qtopbase, dp);
	+ 		s -= (Qunitdir-Qtopbase);
	  
	  		qlock(&devslock);
	- 		for(i = 0; i != ndevs; i++){
	- 			if(s < devs[i].nunits)
	- 				break;
	- 			s -= devs[i].nunits;
	+ 		for(i=0; i<nelem(devs); i++){
	+ 			if(devs[i]){
	+ 				if(s < devs[i]->nunit)
	+ 					break;
	+ 				s -= devs[i]->nunit;
	+ 			}
	  		}
	  		
	- 		if(i == ndevs){
	- 			/* Run of the end of the list */
	+ 		if(i == nelem(devs)){
	+ 			/* Run off the end of the list */
	  			qunlock(&devslock);
	  			return -1;
	  		}
	  
	- 		if((sdev = devs[i].dev) == nil){
	+ 		if((sdev = devs[i]) == nil){
	  			qunlock(&devslock);
	  			return 0;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:572,578 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:566,571
	  		decref(&sdev->r);
	  		return r;
	  	case Qtopctl:
	- 	case Qtopstat:
	  		return sd1gen(c, TYPE(c->qid), dp);
	  	default:
	  		break;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:587,595 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:580,588
	  	Chan *c;
	  	char *p;
	  	SDev *sdev;
	- 	int idno, subno, i;
	+ 	int idno, subno;
	  
	- 	if(ndevs == 0 || *spec == '\0'){
	+ 	if(*spec == '\0'){
	  		c = devattach(sddevtab.dc, spec);
	  		mkqid(&c->qid, QID(0, 0, 0, Qtopdir), 0, QTDIR);
	  		return c;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:602,618 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:595,606
	  	if(p == &spec[3])
	  		error(Ebadspec);
	  
	- 	qlock(&devslock);
	- 	for (sdev = nil, i = 0; i != ndevs; i++)
	- 		if((sdev = devs[i].dev) != nil && sdev->idno == idno)
	- 			break;
	- 
	- 	if(i == ndevs || subno >= sdev->nunit || sdgetunit(sdev, subno) == nil){
	- 		qunlock(&devslock);
	+ 	if((sdev=sdgetdev(idno)) == nil)
	  		error(Enonexist);
	+ 	if(sdgetunit(sdev, subno) == nil){
	+ 		decref(&sdev->r);
	+ 		error(Enonexist);
	  	}
	- 	incref(&sdev->r);
	- 	qunlock(&devslock);
	  
	  	c = devattach(sddevtab.dc, spec);
	  	mkqid(&c->qid, QID(sdev->idno, subno, 0, Qunitdir), 0, QTDIR);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:738,744 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:726,732
	  	}
	  	pp = &unit->part[PART(c->qid)];
	  	if(unit->vers+pp->vers != c->qid.vers)
	- 		error(Eio);
	+ 		error(Echange);
	  
	  	/*
	  	 * Check the request is within bounds.
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:867,872 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:855,1049
	  	return r->rlen;
	  }
	  
	+ /*
	+  * SCSI simulation for non-SCSI devices
	+  */
	+ int
	+ sdsetsense(SDreq *r, int status, int key, int asc, int ascq)
	+ {
	+ 	int len;
	+ 	SDunit *unit;
	+ 	
	+ 	unit = r->unit;
	+ 	unit->sense[2] = key;
	+ 	unit->sense[12] = asc;
	+ 	unit->sense[13] = ascq;
	+ 
	+ 	if(status == SDcheck && !(r->flags & SDnosense)){
	+ 		/* request sense case from sdfakescsi */
	+ 		len = sizeof unit->sense;
	+ 		if(len > sizeof r->sense-1)
	+ 			len = sizeof r->sense-1;
	+ 		memmove(r->sense, unit->sense, len);
	+ 		unit->sense[2] = 0;
	+ 		unit->sense[12] = 0;
	+ 		unit->sense[13] = 0;
	+ 		r->flags |= SDvalidsense;
	+ 		return SDok;
	+ 	}
	+ 	return status;
	+ }
	+ 
	+ int
	+ sdmodesense(SDreq *r, uchar *cmd, void *info, int ilen)
	+ {
	+ 	int len;
	+ 	uchar *data;
	+ 	
	+ 	/*
	+ 	 * Fake a vendor-specific request with page code 0,
	+ 	 * return the drive info.
	+ 	 */
	+ 	if((cmd[2] & 0x3F) != 0 && (cmd[2] & 0x3F) != 0x3F)
	+ 		return sdsetsense(r, SDcheck, 0x05, 0x24, 0);
	+ 	len = (cmd[7]<<8)|cmd[8];
	+ 	if(len == 0)
	+ 		return SDok;
	+ 	if(len < 8+ilen)
	+ 		return sdsetsense(r, SDcheck, 0x05, 0x1A, 0);
	+ 	if(r->data == nil || r->dlen < len)
	+ 		return sdsetsense(r, SDcheck, 0x05, 0x20, 1);
	+ 	data = r->data;
	+ 	memset(data, 0, 8);
	+ 	data[0] = ilen>>8;
	+ 	data[1] = ilen;
	+ 	if(ilen)
	+ 		memmove(data+8, info, ilen);
	+ 	r->rlen = 8+ilen;
	+ 	return sdsetsense(r, SDok, 0, 0, 0);
	+ }
	+ 
	+ int
	+ sdfakescsi(SDreq *r, void *info, int ilen)
	+ {
	+ 	uchar *cmd, *p;
	+ 	uvlong len;
	+ 	SDunit *unit;
	+ 	
	+ 	cmd = r->cmd;
	+ 	r->rlen = 0;
	+ 	unit = r->unit;
	+ 	
	+ 	/*
	+ 	 * Rewrite read(6)/write(6) into read(10)/write(10).
	+ 	 */
	+ 	switch(cmd[0]){
	+ 	case 0x08:	/* read */
	+ 	case 0x0A:	/* write */
	+ 		cmd[9] = 0;
	+ 		cmd[8] = cmd[4];
	+ 		cmd[7] = 0;
	+ 		cmd[6] = 0;
	+ 		cmd[5] = cmd[3];
	+ 		cmd[4] = cmd[2];
	+ 		cmd[3] = cmd[1] & 0x0F;
	+ 		cmd[2] = 0;
	+ 		cmd[1] &= 0xE0;
	+ 		cmd[0] |= 0x20;
	+ 		break;
	+ 	}
	+ 
	+ 	/*
	+ 	 * Map SCSI commands into ATA commands for discs.
	+ 	 * Fail any command with a LUN except INQUIRY which
	+ 	 * will return 'logical unit not supported'.
	+ 	 */
	+ 	if((cmd[1]>>5) && cmd[0] != 0x12)
	+ 		return sdsetsense(r, SDcheck, 0x05, 0x25, 0);
	+ 	
	+ 	switch(cmd[0]){
	+ 	default:
	+ 		return sdsetsense(r, SDcheck, 0x05, 0x20, 0);
	+ 	
	+ 	case 0x00:	/* test unit ready */
	+ 		return sdsetsense(r, SDok, 0, 0, 0);
	+ 	
	+ 	case 0x03:	/* request sense */
	+ 		if(cmd[4] < sizeof unit->sense)
	+ 			len = cmd[4];
	+ 		else
	+ 			len = sizeof unit->sense;
	+ 		if(r->data && r->dlen >= len){
	+ 			memmove(r->data, unit->sense, len);
	+ 			r->rlen = len;
	+ 		}
	+ 		return sdsetsense(r, SDok, 0, 0, 0);
	+ 	
	+ 	case 0x12:	/* inquiry */
	+ 		if(cmd[4] < sizeof unit->inquiry)
	+ 			len = cmd[4];
	+ 		else
	+ 			len = sizeof unit->inquiry;
	+ 		if(r->data && r->dlen >= len){
	+ 			memmove(r->data, r->sense, len);
	+ 			r->rlen = len;
	+ 		}
	+ 		return sdsetsense(r, SDok, 0, 0, 0);
	+ 
	+ 	case 0x1B:	/* start/stop unit */
	+ 		/*
	+ 		 * nop for now, can use power management later.
	+ 		 */
	+ 		return sdsetsense(r, SDok, 0, 0, 0);
	+ 	
	+ 	case 0x25:	/* read capacity */
	+ 		if((cmd[1] & 0x01) || cmd[2] || cmd[3])
	+ 			return sdsetsense(r, SDcheck, 0x05, 0x24, 0);
	+ 		if(r->data == nil || r->dlen < 8)
	+ 			return sdsetsense(r, SDcheck, 0x05, 0x20, 1);
	+ 		
	+ 		/*
	+ 		 * Read capacity returns the LBA of the last sector.
	+ 		 */
	+ 		len = unit->sectors - 1;
	+ 		p = r->data;
	+ 		*p++ = len>>24;
	+ 		*p++ = len>>16;
	+ 		*p++ = len>>8;
	+ 		*p++ = len;
	+ 		len = 512;
	+ 		*p++ = len>>24;
	+ 		*p++ = len>>16;
	+ 		*p++ = len>>8;
	+ 		*p++ = len;
	+ 		r->rlen = p - (uchar*)r->data;
	+ 		return sdsetsense(r, SDok, 0, 0, 0);
	+ 
	+ 	case 0x9E:	/* long read capacity */
	+ 		if((cmd[1] & 0x01) || cmd[2] || cmd[3])
	+ 			return sdsetsense(r, SDcheck, 0x05, 0x24, 0);
	+ 		if(r->data == nil || r->dlen < 8)
	+ 			return sdsetsense(r, SDcheck, 0x05, 0x20, 1);	
	+ 		/*
	+ 		 * Read capcity returns the LBA of the last sector.
	+ 		 */
	+ 		len = unit->sectors - 1;
	+ 		p = r->data;
	+ 		*p++ = len>>56;
	+ 		*p++ = len>>48;
	+ 		*p++ = len>>40;
	+ 		*p++ = len>>32;
	+ 		*p++ = len>>24;
	+ 		*p++ = len>>16;
	+ 		*p++ = len>>8;
	+ 		*p++ = len;
	+ 		len = 512;
	+ 		*p++ = len>>24;
	+ 		*p++ = len>>16;
	+ 		*p++ = len>>8;
	+ 		*p++ = len;
	+ 		r->rlen = p - (uchar*)r->data;
	+ 		return sdsetsense(r, SDok, 0, 0, 0);
	+ 	
	+ 	case 0x5A:	/* mode sense */
	+ 		return sdmodesense(r, cmd, info, ilen);
	+ 	
	+ 	case 0x28:	/* read */
	+ 	case 0x2A:	/* write */
	+ 		return SDnostatus;
	+ 	}
	+ }
	+ 
	  static long
	  sdread(Chan *c, void *a, long n, vlong off)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:875,898 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:1052,1073
	  	SDunit *unit;
	  	SDev *sdev;
	  	ulong offset;
	- 	int i, l, status;
	+ 	int i, l, m, status;
	  
	  	offset = off;
	  	switch(TYPE(c->qid)){
	  	default:
	  		error(Eperm);
	- 	case Qtopstat:
	- 		p = buf = malloc(READSTR);
	+ 	case Qtopctl:
	+ 		m = 64*1024;	/* room for register dumps */
	+ 		p = buf = malloc(m);
	  		assert(p);
	- 		e = p + READSTR;
	+ 		e = p + m;
	  		qlock(&devslock);
	- 		for(i = 0; i != ndevs; i++){
	- 			SDev *sdev = devs[i].dev;
	- 
	- 			if(sdev->ifc->stat)
	- 				p = sdev->ifc->stat(sdev, p, e);
	- 			else
	- 				p = seprint(e, "%s; no statistics available\n", sdev->name);
	+ 		for(i = 0; i < nelem(devs); i++){
	+ 			sdev = devs[i];
	+ 			if(sdev && sdev->ifc->rtopctl)
	+ 				p = sdev->ifc->rtopctl(sdev, p, e);
	  		}
	  		qunlock(&devslock);
	  		n = readstr(off, a, n, buf);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:909,916 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:1084,1092
	  			error(Enonexist);
	  
	  		unit = sdev->unit[UNIT(c->qid)];
	- 		p = malloc(READSTR);
	- 		l = snprint(p, READSTR, "inquiry %.48s\n",
	+ 		m = 16*1024;	/* room for register dumps */
	+ 		p = malloc(m);
	+ 		l = snprint(p, m, "inquiry %.48s\n",
	  			(char*)unit->inquiry+8);
	  		qlock(&unit->ctl);
	  		/*
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:919,936 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:1095,1112
	  		 * and the garscadden trains.
	  		 */
	  		if(unit->dev->ifc->rctl)
	- 			l += unit->dev->ifc->rctl(unit, p+l, READSTR-l);
	+ 			l += unit->dev->ifc->rctl(unit, p+l, m-l);
	  		if(unit->sectors == 0)
	  			sdinitpart(unit);
	  		if(unit->sectors){
	  			if(unit->dev->ifc->rctl == nil)
	- 				l += snprint(p+l, READSTR-l,
	+ 				l += snprint(p+l, m-l,
	  					"geometry %ld %ld\n",
	  					unit->sectors, unit->secsize);
	  			pp = unit->part;
	  			for(i = 0; i < unit->npart; i++){
	  				if(pp->valid)
	- 					l += snprint(p+l, READSTR-l,
	+ 					l += snprint(p+l, m-l,
	  						"part %s %lud %lud\n",
	  						pp->name, pp->start, pp->end);
	  				pp++;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:978,1142 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:1154,1227
	  	return 0;
	  }
	  
	- typedef struct Confdata Confdata;
	- struct Confdata {
	- 	int	on;
	- 	char*	spec;
	- 	DevConf	cf;
	- };
	+ static void legacytopctl(Cmdbuf*);
	  
	- static void
	- parseswitch(Confdata* cd, char* option)
	- {
	- 	if(!strcmp("on", option))
	- 		cd->on = 1;
	- 	else if(!strcmp("off", option))
	- 		cd->on = 0;
	- 	else
	- 		error(Ebadarg);
	- }
	- 
	- static void
	- parsespec(Confdata* cd, char* option)
	- {
	- 	if(strlen(option) > 1) 
	- 		error(Ebadarg);
	- 	cd->spec = option;
	- }
	- 
	- static Devport*
	- getnewport(DevConf* dc)
	- {
	- 	Devport *p;
	- 
	- 	p = (Devport *)malloc((dc->nports + 1) * sizeof(Devport));
	- 	if(dc->nports > 0){
	- 		memmove(p, dc->ports, dc->nports * sizeof(Devport));
	- 		free(dc->ports);
	- 	}
	- 	dc->ports = p;
	- 	p = &dc->ports[dc->nports++];
	- 	p->size = -1;
	- 	p->port = (ulong)-1;
	- 	return p;
	- }
	- 
	- static void
	- parseport(Confdata* cd, char* option)
	- {
	- 	char *e;
	- 	Devport *p;
	- 
	- 	if(cd->cf.nports == 0 || cd->cf.ports[cd->cf.nports-1].port != (ulong)-1)
	- 		p = getnewport(&cd->cf);
	- 	else
	- 		p = &cd->cf.ports[cd->cf.nports-1];
	- 	p->port = strtol(option, &e, 0);
	- 	if(e == nil || *e != '\0')
	- 		error(Ebadarg);
	- }
	- 
	- static void
	- parsesize(Confdata* cd, char* option)
	- {
	- 	char *e;
	- 	Devport *p;
	- 
	- 	if(cd->cf.nports == 0 || cd->cf.ports[cd->cf.nports-1].size != -1)
	- 		p = getnewport(&cd->cf);
	- 	else
	- 		p = &cd->cf.ports[cd->cf.nports-1];
	- 	p->size = (int)strtol(option, &e, 0);
	- 	if(e == nil || *e != '\0')
	- 		error(Ebadarg);
	- }
	- 
	- static void
	- parseirq(Confdata* cd, char* option)
	- {
	- 	char *e;
	- 
	- 	cd->cf.intnum = strtoul(option, &e, 0);
	- 	if(e == nil || *e != '\0')
	- 		error(Ebadarg);
	- }
	- 
	- static void
	- parsetype(Confdata* cd, char* option)
	- {
	- 	cd->cf.type = option;
	- }
	- 
	- static struct {
	- 	char	*option;
	- 	void	(*parse)(Confdata*, char*);
	- } options[] = {
	- 	{ 	"switch",	parseswitch,	},
	- 	{	"spec",		parsespec,	},
	- 	{	"port",		parseport,	},
	- 	{	"size",		parsesize,	},
	- 	{	"irq",		parseirq,	},
	- 	{	"type",		parsetype,	},
	- };
	- 
	  static long
	  sdwrite(Chan* c, void* a, long n, vlong off)
	  {
	+ 	char *f0;
	+ 	int i;
	+ 	ulong end, start;
	  	Cmdbuf *cb;
	+ 	SDifc *ifc;
	  	SDreq *req;
	  	SDunit *unit;
	  	SDev *sdev;
	- 	ulong end, start;
	  
	  	switch(TYPE(c->qid)){
	  	default:
	  		error(Eperm);
	- 	case Qtopctl: {
	- 		Confdata cd;
	- 		char buf[256], *field[Ncmd];
	- 		int nf, i, j;
	- 
	- 		memset(&cd, 0, sizeof(Confdata));
	- 		if(n > sizeof(buf)-1) n = sizeof(buf)-1;
	- 		memmove(buf, a, n);
	- 		buf[n] = '\0';
	- 
	- 		cd.on = -1;
	- 		cd.spec = '\0';
	- 		memset(&cd.cf, 0, sizeof(DevConf));
	- 
	- 		nf = tokenize(buf, field, Ncmd);
	- 		for(i = 0; i < nf; i++){
	- 			char *opt = field[i++];
	- 			if(i >= nf)
	- 				error(Ebadarg);
	- 			for(j = 0; j != nelem(options); j++)
	- 				if(!strcmp(opt, options[j].option))
	- 					break;
	- 					
	- 			if(j == nelem(options))
	- 				error(Ebadarg);
	- 			options[j].parse(&cd, field[i]);
	+ 	case Qtopctl:
	+ 		cb = parsecmd(a, n);
	+ 		if(waserror()){
	+ 			free(cb);
	+ 			nexterror();
	  		}
	- 
	- 		if(cd.on < 0) 
	- 			error(Ebadarg);
	- 
	- 		if(cd.on){
	- 			if(cd.spec == '\0' || cd.cf.nports == 0 || 
	- 			     cd.cf.intnum == 0 || cd.cf.type == nil)
	- 				error(Ebadarg);
	+ 		if(cb->nf == 0)
	+ 			error("empty control message");
	+ 		f0 = cb->f[0];
	+ 		cb->f++;
	+ 		cb->nf--;
	+ 		if(strcmp(f0, "config") == 0){
	+ 			/* wormhole into ugly legacy interface */
	+ 			legacytopctl(cb);
	+ 			poperror();
	+ 			free(cb);
	+ 			break;
	  		}
	- 		else{
	- 			if(cd.spec == '\0')
	- 				error(Ebadarg);
	+ 		ifc = nil;
	+ 		sdev = nil;
	+ 		for(i=0; sdifc[i]; i++){
	+ 			if(strcmp(sdifc[i]->name, f0) == 0){
	+ 				ifc = sdifc[i];
	+ 				sdev = nil;
	+ 				goto subtopctl;
	+ 			}
	  		}
	- 
	- 		if(sddevtab.config == nil)
	- 			error("No configuration function");
	- 		sddevtab.config(cd.on, cd.spec, &cd.cf);
	+ 		if(f0[0]=='s' && f0[1]=='d' && f0[2] && f0[3] == 0){
	+ 			if((sdev = sdgetdev(f0[2])) != nil){
	+ 				ifc = sdev->ifc;
	+ 				goto subtopctl;
	+ 			}
	+ 		}
	+ 		error("unknown interface");
	+ 	
	+ 	subtopctl:
	+ 		if(waserror()){
	+ 			if(sdev)
	+ 				decref(&sdev->r);
	+ 			nexterror();
	+ 		}
	+ 		if(ifc->wtopctl)
	+ 			ifc->wtopctl(sdev, cb);
	+ 		else
	+ 			error(Ebadctl);
	+ 		poperror();
	+ 		poperror();
	+ 		decref(&sdev->r);
	+ 		free(cb);
	  		break;
	- 	}
	+ 
	  	case Qctl:
	  		cb = parsecmd(a, n);
	  		sdev = sdgetdev(DEV(c->qid));
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:1152,1158 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:1237,1243
	  			nexterror();
	  		}
	  		if(unit->vers != c->qid.vers)
	- 			error(Eio);
	+ 			error(Echange);
	  
	  		if(cb->nf < 1)
	  			error(Ebadctl);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:1293,1395 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:1378,1411
	  	return n;
	  }
	  
	- static char
	- getspec(char base)
	- {
	- 	while(1){
	- 		int i;
	- 		SDev *sdev;
	- 
	- 		for(i = 0; i != ndevs; i++)
	- 			if((sdev = devs[i].dev) != nil && (char)sdev->idno == base)
	- 				break;
	- 
	- 		if(i == ndevs)
	- 			return base;
	- 		base++;
	- 	}
	- 	return '\0';
	- }
	- 
	  static int
	  configure(char* spec, DevConf* cf)
	  {
	- 	ISAConf isa;
	- 	SDevgrp *tmpdevs;
	- 	SDev *tail, *sdev, *(*probe)(DevConf*);
	- 	char *p, name[32];
	- 	int i, nnew;
	+ 	SDev *s, *sdev;
	+ 	char *p;
	+ 	int i;
	  
	+ 	if(sdindex(*spec) < 0)
	+ 		error("bad sd spec");
	+ 
	  	if((p = strchr(cf->type, '/')) != nil)
	  		*p++ = '\0';
	  
	  	for(i = 0; sdifc[i] != nil; i++)
	- 		if(!strcmp(sdifc[i]->name, cf->type))
	+ 		if(strcmp(sdifc[i]->name, cf->type) == 0)
	  			break;
	- 
	  	if(sdifc[i] == nil)
	- 		error("type not found");
	- 	
	- 	if((probe = sdifc[i]->probe) == nil)
	- 		error("No probe function");
	+ 		error("sd type not found");
	+ 	if(p)
	+ 		*(p-1) = '/';
	  
	- 	if(p){
	- 		/* Try to find the card on the ISA bus.  This code really belongs
	- 		     in sdata and I'll move it later.  Really! */
	- 		memset(&isa, 0, sizeof(isa));
	- 		isa.port = cf->ports[0].port;
	- 		isa.irq = cf->intnum;
	+ 	if(sdifc[i]->probe == nil)
	+ 		error("sd type cannot probe");
	  
	- 		if(pcmspecial(p, &isa) < 0)
	- 			error("Cannot find controller");
	- 	}
	- 
	- 	qlock(&devslock);
	- 	if(waserror()){
	- 		qunlock(&devslock);
	- 		nexterror();
	- 	}
	- 	
	- 	for(i = 0; i != ndevs; i++)
	- 		if((sdev = devs[i].dev) != nil && sdev->idno == *spec)
	- 			break;
	- 	if(i != ndevs)
	- 		error(Eexist);
	- 
	- 	if((sdev = (*probe)(cf)) == nil)
	- 		error("Cannot probe controller");
	- 	poperror();
	- 
	- 	nnew = 0;
	- 	tail = sdev;
	- 	while(tail){
	- 		nnew++;
	- 		tail = tail->next;
	- 	}
	- 	
	- 	tmpdevs = (SDevgrp*)malloc((ndevs + nnew) * sizeof(SDevgrp));
	- 	memmove(tmpdevs, devs, ndevs * sizeof(SDevgrp));
	- 	free(devs);
	- 	devs = tmpdevs;
	- 
	- 	while(sdev){
	- 		/* Assign `spec' to the device */
	- 		*spec = getspec(*spec);
	- 		snprint(name, sizeof(name), "sd%c", *spec);
	- 		kstrdup(&sdev->name, name);
	- 		sdev->idno = *spec;
	- 		sdev->unit = (SDunit **)malloc(sdev->nunit * sizeof(SDunit*));
	- 		sdev->unitflg = (int *)malloc(sdev->nunit * sizeof(int));
	- 		assert(sdev->unit && sdev->unitflg);
	- 
	- 		devs[ndevs].dev = sdev;
	- 		devs[ndevs].nunits = sdev->nunit;
	- 		sdev = sdev->next;
	- 		devs[ndevs].dev->next = nil;
	- 		ndevs++;
	- 	}
	- 
	- 	qunlock(&devslock);
	+ 	sdev = sdifc[i]->probe(cf);
	+ 	for(s=sdev; s; s=s->next)
	+ 		s->idno = *spec;
	+ 	sdadddevs(sdev);
	  	return 0;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:1398,1444 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:1414,1451
	  {
	  	int i;	
	  	SDev *sdev;
	+ 	SDunit *unit;
	  
	+ 	if((i = sdindex(*spec)) < 0)
	+ 		error(Enonexist);
	+ 
	  	qlock(&devslock);
	- 	if(waserror()){
	+ 	if((sdev = devs[i]) == nil){
	  		qunlock(&devslock);
	- 		nexterror();
	- 	}
	- 
	- 	sdev = nil;
	- 	for(i = 0; i != ndevs; i++)
	- 		if((sdev = devs[i].dev) != nil && sdev->idno == *spec)
	- 			break;
	- 
	- 	if(i == ndevs)
	  		error(Enonexist);
	- 
	- 	if(sdev->r.ref)
	+ 	}
	+ 	if(sdev->r.ref){
	+ 		qunlock(&devslock);
	  		error(Einuse);
	- 
	+ 	}
	+ 	devs[i] = nil;
	+ 	qunlock(&devslock);
	+ 	
	  	/* make sure no interrupts arrive anymore before removing resources */
	  	if(sdev->enabled && sdev->ifc->disable)
	  		sdev->ifc->disable(sdev);
	  
	- 	/* we're alone and the device tab is locked; make the device unavailable */
	- 	memmove(&devs[i], &devs[ndevs - 1], sizeof(SDevgrp));
	- 	memset(&devs[ndevs - 1], 0, sizeof(SDevgrp));
	- 	ndevs--;
	- 
	- 	qunlock(&devslock);
	- 	poperror();
	- 
	- 	for(i = 0; i != sdev->nunit; i++)
	- 		if(sdev->unit[i]){
	- 			SDunit *unit = sdev->unit[i];
	- 
	+ 	for(i = 0; i != sdev->nunit; i++){
	+ 		if(unit = sdev->unit[i]){
	  			free(unit->name);
	  			free(unit->user);
	  			free(unit);
	  		}
	+ 	}
	  
	  	if(sdev->ifc->clear)
	  		sdev->ifc->clear(sdev);
	+ 	free(sdev);
	  	return 0;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsd.c:1472,1474 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsd.c:1479,1617
	  	devpower,
	  	sdconfig,
	  };
	+ 
	+ /*
	+  * This is wrong for so many reasons.  This code must go.
	+  */
	+ typedef struct Confdata Confdata;
	+ struct Confdata {
	+ 	int	on;
	+ 	char*	spec;
	+ 	DevConf	cf;
	+ };
	+ 
	+ static void
	+ parseswitch(Confdata* cd, char* option)
	+ {
	+ 	if(!strcmp("on", option))
	+ 		cd->on = 1;
	+ 	else if(!strcmp("off", option))
	+ 		cd->on = 0;
	+ 	else
	+ 		error(Ebadarg);
	+ }
	+ 
	+ static void
	+ parsespec(Confdata* cd, char* option)
	+ {
	+ 	if(strlen(option) > 1) 
	+ 		error(Ebadarg);
	+ 	cd->spec = option;
	+ }
	+ 
	+ static Devport*
	+ getnewport(DevConf* dc)
	+ {
	+ 	Devport *p;
	+ 
	+ 	p = (Devport *)malloc((dc->nports + 1) * sizeof(Devport));
	+ 	if(dc->nports > 0){
	+ 		memmove(p, dc->ports, dc->nports * sizeof(Devport));
	+ 		free(dc->ports);
	+ 	}
	+ 	dc->ports = p;
	+ 	p = &dc->ports[dc->nports++];
	+ 	p->size = -1;
	+ 	p->port = (ulong)-1;
	+ 	return p;
	+ }
	+ 
	+ static void
	+ parseport(Confdata* cd, char* option)
	+ {
	+ 	char *e;
	+ 	Devport *p;
	+ 
	+ 	if(cd->cf.nports == 0 || cd->cf.ports[cd->cf.nports-1].port != (ulong)-1)
	+ 		p = getnewport(&cd->cf);
	+ 	else
	+ 		p = &cd->cf.ports[cd->cf.nports-1];
	+ 	p->port = strtol(option, &e, 0);
	+ 	if(e == nil || *e != '\0')
	+ 		error(Ebadarg);
	+ }
	+ 
	+ static void
	+ parsesize(Confdata* cd, char* option)
	+ {
	+ 	char *e;
	+ 	Devport *p;
	+ 
	+ 	if(cd->cf.nports == 0 || cd->cf.ports[cd->cf.nports-1].size != -1)
	+ 		p = getnewport(&cd->cf);
	+ 	else
	+ 		p = &cd->cf.ports[cd->cf.nports-1];
	+ 	p->size = (int)strtol(option, &e, 0);
	+ 	if(e == nil || *e != '\0')
	+ 		error(Ebadarg);
	+ }
	+ 
	+ static void
	+ parseirq(Confdata* cd, char* option)
	+ {
	+ 	char *e;
	+ 
	+ 	cd->cf.intnum = strtoul(option, &e, 0);
	+ 	if(e == nil || *e != '\0')
	+ 		error(Ebadarg);
	+ }
	+ 
	+ static void
	+ parsetype(Confdata* cd, char* option)
	+ {
	+ 	cd->cf.type = option;
	+ }
	+ 
	+ static struct {
	+ 	char	*name;
	+ 	void	(*parse)(Confdata*, char*);
	+ } options[] = {
	+ 	"switch",	parseswitch,
	+ 	"spec",		parsespec,
	+ 	"port",		parseport,
	+ 	"size",		parsesize,
	+ 	"irq",		parseirq,
	+ 	"type",		parsetype,
	+ };
	+ 
	+ static void
	+ legacytopctl(Cmdbuf *cb)
	+ {
	+ 	char *opt;
	+ 	int i, j;
	+ 	Confdata cd;
	+ 
	+ 	memset(&cd, 0, sizeof cd);
	+ 	cd.on = -1;
	+ 	for(i=0; i<cb->nf; i+=2){
	+ 		if(i+2 > cb->nf)
	+ 			error(Ebadarg);
	+ 		opt = cb->f[i];
	+ 		for(j=0; j<nelem(options); j++)
	+ 			if(strcmp(opt, options[j].name) == 0){
	+ 				options[j].parse(&cd, cb->f[i+1]);
	+ 				break;
	+ 			}
	+ 		if(j == nelem(options))
	+ 			error(Ebadarg);
	+ 	}
	+ 	if(cd.on < 0)
	+ 		error(Ebadarg);
	+ 	if(cd.on
	+ 	&& (cd.spec == 0 || cd.cf.nports == 0 || cd.cf.intnum == 0 || cd.cf.type == nil))
	+ 		error(Ebadarg);
	+ 	if(!cd.on && cd.spec == 0)
	+ 		error(Ebadarg);
	+ 	sdconfig(cd.on, cd.spec, &cd.cf);
	+ }
	+ 	
 [rsc] --rw-rw-r-- M 451989 glenda sys 9610 Nov  6 10:11 sys/src/9/port/devsegment.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/devsegment.c:486,492 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/devsegment.c:486,492
	  	s = g->s;
	  	if(s == nil)
	  		error("global segment not assigned a virtual address");
	- 	if(isoverlap(p, s->base, s->top) != nil)
	+ 	if(isoverlap(p, s->base, s->top - s->base) != nil)
	  		error("overlaps existing segment");
	  	incref(s);
	  	unlock(&globalseglock);
 [rsc] --rw-rw-r-- M 451989 glenda sys 7271 Nov  6 10:11 sys/src/9/port/fault.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/fault.c:352,358 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/fault.c:352,358
	  			return t;
	  		a += m;
	  		n -= m;
	- 		if((a & KZERO) != KZERO)
	+ 		if(a < KZERO)
	  			validaddr(a, 1, 0);
	  	}
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 6040 Nov  6 10:11 sys/src/9/port/lib.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/lib.h:1,6 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/lib.h:1,9
	  /*
	   * functions (possibly) linked in, complete, from libc.
	   */
	+ #define nelem(x)	(sizeof(x)/sizeof((x)[0]))
	+ #define offsetof(s, m)	(ulong)(&(((s*)0)->m))
	+ #define assert(x)	if(x){}else _assert("x")
	  
	  /*
	   * mem routines
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/lib.h:27,32 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/lib.h:30,37
	  extern	char*	strstr(char*, char*);
	  extern	int	atoi(char*);
	  extern	int	fullrune(char*, int);
	+ extern	int	cistrcmp(char*, char*);
	+ extern	int	cistrncmp(char*, char*, int);
	  
	  enum
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/lib.h:103,108 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/lib.h:108,114
	  extern	int	getfields(char*, char**, int, int, char*);
	  extern	int	tokenize(char*, char**, int);
	  extern	int	dec64(uchar*, int, char*, int);
	+ extern	void	qsort(void*, long, long, int (*)(void*, void*));
	  
	  /*
	   * Syscall data structures
 [rsc] --rw-rw-r-- M 451989 glenda sys 510 Nov  6 10:12 sys/src/9/port/master
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/master:40,45 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/master:40,46
	  s	srv
	  t	uart
	  v	vga
	+ w	wd
	  y	i82365
	  y	pcmcia
	  z	mntstats
 [rsc] --rw-rw-r-- M 451989 glenda sys 8449 Nov  6 10:12 sys/src/9/port/page.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/page.c:12,22 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/page.c:12,27
	  void
	  pageinit(void)
	  {
	- 	int color;
	+ 	int color, i, j;
	  	Page *p;
	- 	ulong np, vm, pm;
	+ 	Pallocmem *pm;
	+ 	ulong m, np, k, vkb, pkb;
	  
	- 	np = palloc.np0+palloc.np1;
	+ 	np = 0;
	+ 	for(i=0; i<nelem(palloc.mem); i++){
	+ 		pm = &palloc.mem[i];
	+ 		np += pm->npage;
	+ 	}
	  	palloc.head = xalloc(np*sizeof(Page));
	  	if(palloc.head == 0)
	  		panic("pageinit");
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/page.c:23,65 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/page.c:28,66
	  
	  	color = 0;
	  	p = palloc.head;
	- 	while(palloc.np0 > 0) {
	- 		p->prev = p-1;
	- 		p->next = p+1;
	- 		p->pa = palloc.p0;
	- 		p->color = color;
	- 		palloc.freecount++;
	- 		color = (color+1)%NCOLOR;
	- 		palloc.p0 += BY2PG;
	- 		palloc.np0--;
	- 		p++;
	+ 	for(i=0; i<nelem(palloc.mem); i++){
	+ 		pm = &palloc.mem[i];
	+ 		for(j=0; j<pm->npage; j++){
	+ 			p->prev = p-1;
	+ 			p->next = p+1;
	+ 			p->pa = pm->base+j*BY2PG;
	+ 			p->color = color;
	+ 			palloc.freecount++;
	+ 			color = (color+1)%NCOLOR;
	+ 			p++;
	+ 		}
	  	}
	- 	while(palloc.np1 > 0) {
	- 		p->prev = p-1;
	- 		p->next = p+1;
	- 		p->pa = palloc.p1;
	- 		p->color = color;
	- 		palloc.freecount++;
	- 		color = (color+1)%NCOLOR;
	- 		palloc.p1 += BY2PG;
	- 		palloc.np1--;
	- 		p++;
	- 	}
	  	palloc.tail = p - 1;
	  	palloc.head->prev = 0;
	  	palloc.tail->next = 0;
	  
	  	palloc.user = p - palloc.head;
	- 	pm = palloc.user*BY2PG/1024;
	- 	vm = pm + (conf.nswap*BY2PG)/1024;
	+ 	pkb = palloc.user*BY2PG/1024;
	+ 	vkb = pkb + (conf.nswap*BY2PG)/1024;
	  
	- 	/* Pageing numbers */
	+ 	/* Paging numbers */
	  	swapalloc.highwater = (palloc.user*5)/100;
	  	swapalloc.headroom = swapalloc.highwater + (swapalloc.highwater/4);
	  
	- 	print("%lud free pages, ", palloc.user);
	- 	print("%ludK bytes, ", pm);
	- 	print("%ludK swap\n", vm);
	+ 	m = 0;
	+ 	for(i=0; i<nelem(conf.mem); i++)
	+ 		if(conf.mem[i].npage)
	+ 			m += conf.mem[i].npage*BY2PG;
	+ 	k = PGROUND(end - (char*)KTZERO);
	+ 	print("%ldM memory: ", (m+k+1024*1024-1)/(1024*1024));
	+ 	print("%ldM kernel data, ", (m+k-pkb*1024+1024*1024-1)/(1024*1024));
	+ 	print("%ldM user, ", pkb/1024);
	+ 	print("%ldM swap\n", vkb/1024);
	  }
	  
	  static void
 [rsc] --rw-rw-r-- M 451989 glenda sys 22628 Nov  6 10:12 sys/src/9/port/portdat.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portdat.h:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portdat.h:3,9
	  typedef struct Chan	Chan;
	  typedef struct Cmdbuf	Cmdbuf;
	  typedef struct Cmdtab	Cmdtab;
	+ typedef struct Confmem	Confmem;
	  typedef struct Dev	Dev;
	  typedef struct Dirtab	Dirtab;
	  typedef struct Edf	Edf;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portdat.h:23,28 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portdat.h:24,30
	  typedef struct Page	Page;
	  typedef struct Path	Path;
	  typedef struct Palloc	Palloc;
	+ typedef struct Pallocmem	Pallocmem;
	  typedef struct Perf	Perf;
	  typedef struct PhysUart	PhysUart;
	  typedef struct Pgrp	Pgrp;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portdat.h:176,182 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portdat.h:178,183
	  	int	mrock;
	  	QLock	rockqlock;
	  	int	ismtpt;
	- 	ulong	mountid;
	  	Mntcache*mcp;			/* Mount cache pointer */
	  	Mnt*	mux;			/* Mnt for clients using me for messages */
	  	union {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portdat.h:480,490 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portdat.h:481,496
	  	DELTAFD	= 20		/* incremental increase in Fgrp.fd's */
	  };
	  
	+ struct Pallocmem
	+ {
	+ 	ulong base;
	+ 	ulong npage;
	+ };
	+ 
	  struct Palloc
	  {
	  	Lock;
	- 	ulong	p0, p1;			/* base of pages in bank 0/1 */
	- 	ulong	np0, np1;		/* number of pages in bank 0/1 */
	+ 	Pallocmem	mem[4];
	  	Page	*head;			/* most recently used */
	  	Page	*tail;			/* least recently used */
	  	ulong	freecount;		/* how many pages on free list now */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portdat.h:660,668 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portdat.h:666,674
	  	ulong	pc;		/* DEBUG only */
	  
	  	Lock	rlock;		/* sync sleep/wakeup with postnote */
	- 	Rendez	*r;			/* rendezvous point slept on */
	+ 	Rendez	*r;		/* rendezvous point slept on */
	  	Rendez	sleep;		/* place for syssleep/debug */
	- 	int	notepending;/* note issued but not acted on */
	+ 	int	notepending;	/* note issued but not acted on */
	  	int	kp;		/* true if a kernel process */
	  	Proc	*palarm;	/* Next alarm time */
	  	ulong	alarm;		/* Time of call */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portdat.h:669,676 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portdat.h:675,682
	  	int	newtlb;		/* Pager has changed my pte's, I must flush */
	  	int	noswap;		/* process is not swappable */
	  
	- 	ulong	rendtag;	/* Tag for rendezvous */
	- 	ulong	rendval;	/* Value for rendezvous */
	+ 	uintptr	rendtag;	/* Tag for rendezvous */
	+ 	uintptr	rendval;	/* Value for rendezvous */
	  	Proc	*rendhash;	/* Hash list for tag values */
	  
	  	Timer;			/* For tsleep and real-time */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portdat.h:747,763 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portdat.h:753,770
	  extern	char*	conffile;
	  extern	int	cpuserver;
	  extern	Dev*	devtab[];
	- extern  char*	eve;
	+ extern	char*	eve;
	  extern	char	hostdomain[];
	  extern	uchar	initcode[];
	- extern  Queue*	kbdq;
	- extern  Queue*	kprintoq;
	- extern  Ref	noteidalloc;
	+ extern	int	kbdbuttons;
	+ extern	Queue*	kbdq;
	+ extern	Queue*	kprintoq;
	+ extern 	Ref	noteidalloc;
	+ extern	int	nsyscall;
	  extern	Palloc	palloc;
	- extern  Queue*	serialoq;
	+ extern	Queue*	serialoq;
	  extern	char*	statename[];
	- extern  Image	swapimage;
	- extern	int	nsyscall;
	+ extern	Image	swapimage;
	  extern	char*	sysname;
	  extern	Talarm	talarm;
	  extern	uint	qiomaxatomic;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portdat.h:943,949 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portdat.h:950,956
	  #pragma	varargck	argpos	snprint	3
	  #pragma	varargck	argpos	sprint	2
	  #pragma	varargck	argpos	fprint	2
	- #pragma varargck	argpos	panic	1
	+ #pragma	varargck	argpos	panic	1
	  
	  #pragma	varargck	type	"lld"	vlong
	  #pragma	varargck	type	"llx"	vlong
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portdat.h:972,975 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portdat.h:979,982
	  #pragma	varargck	type	"M"	uchar*
	  #pragma	varargck	type	"p"	void*
	  #pragma	varargck	type	"q"	char*
	- #pragma varargck	flag	','
	+ #pragma	varargck	flag	','
 [rsc] --rw-rw-r-- M 451989 glenda sys 10925 Nov  6 10:12 sys/src/9/port/portfns.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portfns.h:1,3 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portfns.h:1,4
	+ void		_assert(char*);
	  void		accounttime(void);
	  Timer*		addclock0link(void (*)(void), int);
	  int		addphysseg(Physseg*);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portfns.h:8,15 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portfns.h:9,14
	  Block*		allocb(int);
	  int		anyhigher(void);
	  int		anyready(void);
	- #define		assert(x)	if(x){}else _assert("assert(x) failed")
	- void		_assert(char*);
	  Image*		attachimage(int, Chan*, ulong, ulong);
	  Page*		auxpage(void);
	  Block*		bl2mem(uchar*, Block*, int);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portfns.h:176,181 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portfns.h:175,181
	  void		mmuswitch(Proc*);
	  Chan*		mntauth(Chan*, char*);
	  long		mntversion(Chan*, char*, int, int);
	+ void		mouseresize(void);
	  void		mountfree(Mount*);
	  ulong		ms2tk(ulong);
	  ulong		msize(void*);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portfns.h:185,191 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portfns.h:185,190
	  void		muxclose(Mnt*);
	  Chan*		namec(char*, int, int, ulong);
	  void		nameerror(char*, char*);
	- #define		nelem(x)	(sizeof(x)/sizeof(x[0]))
	  Chan*		newchan(void);
	  int		newfd(Chan*);
	  Mhead*		newmhead(Chan*);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portfns.h:211,219 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portfns.h:210,215
	  void		pathclose(Path*);
	  ulong		perfticks(void);
	  void		pexit(char*, int);
	- int		preempted(void);
	- void		printinit(void);
	- int		procindex(ulong);
	  void		pgrpcpy(Pgrp*, Pgrp*);
	  void		pgrpnote(ulong, char*, long, int);
	  void		pio(Segment *, ulong, ulong, Page **);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/portfns.h:220,230 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/portfns.h:216,229
	  #define		poperror()		up->nerrlab--
	  int		postnote(Proc*, int, char*, int);
	  int		pprint(char*, ...);
	+ int		preempted(void);
	  void		prflush(void);
	+ void		printinit(void);
	  ulong		procalarm(ulong);
	  void		procctl(Proc*);
	  void		procdump(void);
	  int		procfdprint(Chan*, int, int, char*, int);
	+ int		procindex(ulong);
	  void		procinit0(void);
	  void		procflushseg(Segment*);
	  void		procpriority(Proc*, int, int);
 [rsc] --rw-rw-r-- M 451989 glenda sys 28264 Nov  6 10:13 sys/src/9/port/proc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/proc.c:113,125 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/proc.c:113,125
	  void
	  sched(void)
	  {
	- 	int x[1];
	  	Proc *p;
	  
	  	if(m->ilockdepth)
	  		panic("ilockdepth %d, last lock 0x%p at 0x%lux, sched called from 0x%lux",
	  			m->ilockdepth, up?up->lastilock:nil,
	- 			(up && up->lastilock)?up->lastilock->pc:0, getcallerpc(x+3));
	+ 			(up && up->lastilock)?up->lastilock->pc:0,
	+ 			getcallerpc(&p+2));
	  
	  	if(up){
	  		if(up->nlocks.ref && up->state != Moribund && up->delaysched < 20){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/proc.c:688,695 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/proc.c:688,697
	  	int i;
	  
	  	procalloc.free = xalloc(conf.nproc*sizeof(Proc));
	- 	if(procalloc.free == nil)
	- 		panic("cannot allocate %lud procs\n", conf.nproc);
	+ 	if(procalloc.free == nil){
	+ 		xsummary();
	+ 		panic("cannot allocate %lud procs (%ludMB)\n", conf.nproc, conf.nproc*sizeof(Proc)/(1024*1024));
	+ 	}
	  	procalloc.arena = procalloc.free;
	  
	  	p = procalloc.free;
 [rsc] --rw-rw-r-- M 451989 glenda sys 2494 Nov  6 10:13 sys/src/9/port/sd.h
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/sd.h:26,31 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/sd.h:26,32
	  	SDev*	dev;
	  	int	subno;
	  	uchar	inquiry[256];		/* format follows SCSI spec */
	+ 	uchar	sense[18];		/* format follows SCSI spec */
	  	SDperm;
	  
	  	QLock	ctl;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/sd.h:45,52 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/sd.h:46,51
	  
	  /* 
	   * Each controller is represented by a SDev.
	-  * Each controller is responsible for allocating its unit structures.
	-  * Each controller has at least one unit.
	   */ 
	  struct SDev {
	  	Ref	r;			/* Number of callers using device */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/sd.h:53,59 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/sd.h:52,58
	  	SDifc*	ifc;			/* pnp/legacy */
	  	void*	ctlr;
	  	int	idno;
	- 	char*	name;
	+ 	char	name[8];
	  	SDev*	next;
	  
	  	QLock;				/* enable/disable */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/sd.h:69,75 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/sd.h:68,73
	  
	  	SDev*	(*pnp)(void);
	  	SDev*	(*legacy)(int, int);
	- 	SDev*	(*id)(SDev*);
	  	int	(*enable)(SDev*);
	  	int	(*disable)(SDev*);
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/sd.h:82,88 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/sd.h:80,87
	  	long	(*bio)(SDunit*, int, int, void*, long, long);
	  	SDev*	(*probe)(DevConf*);
	  	void	(*clear)(SDev*);
	- 	char*	(*stat)(SDev*, char*, char*);
	+ 	char*	(*rtopctl)(SDev*, char*, char*);
	+ 	int	(*wtopctl)(SDev*, Cmdbuf*);
	  };
	  
	  struct SDreq {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/sd.h:124,129 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/sd.h:123,134
	  
	  #define sdmalloc(n)	malloc(n)
	  #define sdfree(p)	free(p)
	+ 
	+ /* devsd.c */
	+ extern void sdadddevs(SDev*);
	+ extern int sdsetsense(SDreq*, int, int, int, int);
	+ extern int sdmodesense(SDreq*, uchar*, void*, int);
	+ extern int sdfakescsi(SDreq*, void*, int);
	  
	  /* sdscsi.c */
	  extern int scsiverify(SDunit*);
 [rsc] --rw-rw-r-- M 451989 glenda sys 13722 Nov  6 12:35 sys/src/9/port/segment.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/segment.c:521,527 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/segment.c:521,527
	  			pg = s->map[i]->pages[j];
	  			/*
	  			 * We want to zero s->map[i]->page[j] and putpage(pg),
	- 			 * but we have to make sure other processors flush the entry
	+ 			 * but we have to make sure other processors flush the
	  			 * entry from their TLBs before the page is freed.
	  			 * We construct a list of the pages to be freed, zero
	  			 * the entries, then (below) call procflushseg, and call
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/segment.c:627,633 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/segment.c:627,633
	  	Segment *s, *os;
	  	Physseg *ps;
	  
	- 	if(va != 0 && (va&KZERO) == KZERO)	/* BUG: Only ok for now */
	+ 	if(va != 0 && va >= USTKTOP)
	  		error(Ebadarg);
	  
	  	validaddr((ulong)name, 1, 0);
 [rsc] --rw-rw-r-- M 451989 glenda sys 3928 Nov  6 10:13 sys/src/9/port/taslock.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/taslock.c:123,162 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/taslock.c:123,162
	  	lockstats.locks++;
	  
	  	x = splhi();
	- 	if(tas(&l->key) == 0){
	- 		m->ilockdepth++;
	- 		if(up)
	- 			up->lastilock = l;
	- 		l->sr = x;
	- 		l->pc = pc;
	- 		l->p = up;
	- 		l->isilock = 1;
	- 		return;
	- 	}
	- 
	- 	lockstats.glare++;
	- 	if(conf.nmach < 2){
	- 		dumplockmem("ilock:", l);
	- 		panic("ilock: no way out: pc %luX\n", pc);
	- 	}
	- 
	- 	for(;;){
	- 		lockstats.inglare++;
	- 		splx(x);
	- 		while(l->key)
	- 			;
	- 		x = splhi();
	- 		if(tas(&l->key) == 0){
	- 			m->ilockdepth++;
	- 			if(up)
	- 				up->lastilock = l;
	- 			l->sr = x;
	- 			l->pc = pc;
	- 			l->p = up;
	- 			l->isilock = 1;
	- 			return;
	+ 	if(tas(&l->key) != 0){
	+ 		lockstats.glare++;
	+ 		/*
	+ 		 * Cannot also check l->pc and l->m here because
	+ 		 * they might just not be set yet, or the lock might 
	+ 		 * even have been let go.
	+ 		 */
	+ 		if(!l->isilock){
	+ 			dumplockmem("ilock:", l);
	+ 			panic("corrupt ilock %p pc=%luX m=%p isilock=%d", 
	+ 				l, l->pc, l->m, l->isilock);
	  		}
	+ 		if(l->m == MACHP(m->machno))
	+ 			panic("ilock: deadlock on cpu%d pc=%luX lockpc=%luX\n", 
	+ 				m->machno, pc, l->pc);
	+ 		for(;;){
	+ 			lockstats.inglare++;
	+ 			splx(x);
	+ 			while(l->key)
	+ 				;
	+ 			x = splhi();
	+ 			if(tas(&l->key) == 0)
	+ 				goto acquire;
	+ 		}
	  	}
	+ acquire:
	+ 	m->ilockdepth++;
	+ 	if(up)
	+ 		up->lastilock = l;
	+ 	l->sr = x;
	+ 	l->pc = pc;
	+ 	l->p = up;
	+ 	l->isilock = 1;
	+ 	l->m = MACHP(m->machno);
	  }
	  
	  int
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/taslock.c:174,179 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/taslock.c:174,180
	  		up->lastlock = l;
	  	l->pc = getcallerpc(&l);
	  	l->p = up;
	+ 	l->m = MACHP(m->machno);
	  	l->isilock = 0;
	  	return 1;
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/taslock.c:187,192 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/taslock.c:188,194
	  		print("unlock of ilock: pc %lux, held by %lux\n", getcallerpc(&l), l->pc);
	  	if(l->p != up)
	  		print("unlock: up changed: pc %lux, acquired at pc %lux, lock p 0x%p, unlock up 0x%p\n", getcallerpc(&l), l->pc, l->p, up);
	+ 	l->m = nil;
	  	l->key = 0;
	  	coherence();
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/taslock.c:212,217 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/taslock.c:214,220
	  		print("iunlock while lo: pc %lux, held by %lux\n", getcallerpc(&l), l->pc);
	  
	  	sr = l->sr;
	+ 	l->m = nil;
	  	l->key = 0;
	  	coherence();
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 4063 Nov  6 10:14 sys/src/9/port/xalloc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/xalloc.c:45,52 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/xalloc.c:45,55
	  void
	  xinit(void)
	  {
	+ 	int i, n, upages, kpages;
	+ 	ulong maxkpa;
	+ 	Confmem *m;
	+ 	Pallocmem *pm;
	  	Hole *h, *eh;
	- 	int upages, np0, np1;
	  
	  	eh = &xlists.hole[Nhole-1];
	  	for(h = xlists.hole; h < eh; h++)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/xalloc.c:55,86 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/xalloc.c:58,94
	  	xlists.flist = xlists.hole;
	  
	  	upages = conf.upages;
	- 	np1 = upages;
	- 	if(np1 > conf.npage1)
	- 		np1 = conf.npage1;
	- 
	- 	palloc.p1 = conf.base1 + (conf.npage1 - np1)*BY2PG;
	- 	conf.npage1 -= np1;
	- 	xhole(conf.base1, conf.npage1*BY2PG);
	- 	conf.npage1 = conf.base1+(conf.npage1*BY2PG);
	- 	upages -= np1;
	- 
	- 	np0 = upages;
	- 	if(np0 > conf.npage0)
	- 		np0 = conf.npage0;
	- 
	- 	palloc.p0 = conf.base0 + (conf.npage0 - np0)*BY2PG;
	- 	conf.npage0 -= np0;
	- 	xhole(conf.base0, conf.npage0*BY2PG);
	- 	conf.npage0 = conf.base0+(conf.npage0*BY2PG);
	- 
	- 	palloc.np0 = np0;
	- 	palloc.np1 = np1;
	- 	/* Save the bounds of kernel alloc memory for kernel mmu mapping */
	- 	conf.base0 = (ulong)KADDR(conf.base0);
	- 	conf.base1 = (ulong)KADDR(conf.base1);
	- 	conf.npage0 = (ulong)KADDR(conf.npage0);
	- 	conf.npage1 = (ulong)KADDR(conf.npage1);
	+ 	kpages = conf.npage - upages;
	+ 	pm = palloc.mem;
	+ 	maxkpa = -KZERO;
	+ 	for(i=0; i<nelem(conf.mem); i++){
	+ 		m = &conf.mem[i];
	+ 		n = m->npage;
	+ 		if(n > kpages)
	+ 			n = kpages;
	+ 		if(m->base >= maxkpa)
	+ 			n = 0;
	+ 		else if(n > 0 && m->base+n*BY2PG >= maxkpa)
	+ 			n = (maxkpa - m->base)/BY2PG;
	+ 		/* first give to kernel */
	+ 		if(n > 0){
	+ 			m->kbase = (ulong)KADDR(m->base);
	+ 			m->klimit = (ulong)KADDR(m->base+n*BY2PG);
	+ 			xhole(m->base, n*BY2PG);
	+ 			kpages -= n;
	+ 		}
	+ 		/* if anything left over, give to user */
	+ 		if(n < m->npage){
	+ 			if(pm >= palloc.mem+nelem(palloc.mem)){
	+ 				print("xinit: losing %lud pages\n", m->npage-n);
	+ 				continue;
	+ 			}
	+ 			pm->base = m->base+n*BY2PG;
	+ 			pm->npage = m->npage - n;
	+ 			pm++;
	+ 		}
	+ 	}
	+ 	xsummary();
	  }
	  
	  void*
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/xalloc.c:122,128 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/xalloc.c:130,136
	  	l = &xlists.table;
	  	for(h = *l; h; h = h->link) {
	  		if(h->size >= size) {
	- 			p = (Xhdr*)h->addr;
	+ 			p = (Xhdr*)KADDR(h->addr);
	  			h->addr += size;
	  			h->size -= size;
	  			if(h->size == 0) {
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/xalloc.c:131,137 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/xalloc.c:139,144
	  				xlists.flist = h;
	  			}
	  			iunlock(&xlists);
	- 			p = KADDR(p);
	  			if(zero)
	  				memset(p->data, 0, size);
	  			p->magix = Magichole;
 [rsc] --rw-rw-r-- M 451989 presotto sys 1076 Nov  6 10:14 sys/src/9/ppc/clock.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/clock.c:57,63 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/clock.c:57,67
	  {
	  	ulong i, j;
	  
	- 	j = m->loopconst;
	+ 	j = 0;
	+ 	if(m)
	+ 		j = m->loopconst;
	+ 	if(j == 0)
	+ 		j = 1096;
	  	while(l-- > 0)
	  		for(i=0; i < j; i++)
	  			;
 [rsc] --rw-rw-r-- M 451989 presotto sys 9327 Nov  6 10:16 sys/src/9/ppc/devether.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/devether.c:11,16 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/devether.c:11,17
	  #include "etherif.h"
	  
	  static Ether *etherxx[MaxEther];
	+ extern uchar etheraddr[];
	  
	  Chan*
	  etherattach(char* spec)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/devether.c:365,370 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/devether.c:366,372
	  		for(n = 0; cards[n].type; n++){
	  			if(cistrcmp(cards[n].type, ether->type))
	  				continue;
	+ 			memmove(ether->ea, etheraddr, 6);
	  			for(i = 0; i < ether->nopt; i++){
	  				if(strncmp(ether->opt[i], "ea=", 3))
	  					continue;
 [rsc] --rw-rw-r-- M 451989 presotto sys 19599 Nov  6 10:15 sys/src/9/ppc/etherfcc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/etherfcc.c:8,19 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/etherfcc.c:8,19
	  #include "dat.h"
	  #include "fns.h"
	  #include "io.h"
	- #include "m8260.h"
	+ #include "imm.h"
	  #include "../port/error.h"
	  #include "../port/netif.h"
	  
	  #include "etherif.h"
	- #include "ethermii.h"
	+ #include "../ppc/ethermii.h"
	  
	  #define DBG 1
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/etherfcc.c:523,545 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/etherfcc.c:523,545
	  		/* Step 1 (Section 28.9), write the parallel ports */
	  		ctlr->pmdio = 0x01000000;
	  		ctlr->pmdck = 0x08000000;
	- 		iomem->port[0].pdir &= ~A1dir0;
	- 		iomem->port[0].pdir |= A1dir1;
	- 		iomem->port[0].psor &= ~A1psor0;
	- 		iomem->port[0].psor |= A1psor1;
	- 		iomem->port[0].ppar |= (A1dir0 | A1dir1);
	+ 		imm->port[0].pdir &= ~A1dir0;
	+ 		imm->port[0].pdir |= A1dir1;
	+ 		imm->port[0].psor &= ~A1psor0;
	+ 		imm->port[0].psor |= A1psor1;
	+ 		imm->port[0].ppar |= (A1dir0 | A1dir1);
	  		/* Step 2, Port C clocks */
	- 		iomem->port[2].psor &= ~0x00000c00;
	- 		iomem->port[2].pdir &= ~0x00000c00;
	- 		iomem->port[2].ppar |= 0x00000c00;
	- 		iomem->port[3].pdat |= (ctlr->pmdio | ctlr->pmdck);
	- 		iomem->port[3].podr |= ctlr->pmdio;
	- 		iomem->port[3].pdir |= (ctlr->pmdio | ctlr->pmdck);
	- 		iomem->port[3].ppar &= ~(ctlr->pmdio | ctlr->pmdck);
	+ 		imm->port[2].psor &= ~0x00000c00;
	+ 		imm->port[2].pdir &= ~0x00000c00;
	+ 		imm->port[2].ppar |= 0x00000c00;
	+ 		imm->port[3].pdat |= (ctlr->pmdio | ctlr->pmdck);
	+ 		imm->port[3].podr |= ctlr->pmdio;
	+ 		imm->port[3].pdir |= (ctlr->pmdio | ctlr->pmdck);
	+ 		imm->port[3].ppar &= ~(ctlr->pmdio | ctlr->pmdck);
	  		eieio();
	  		/* Step 3, Serial Interface clock routing */
	- 		iomem->cmxfcr &= ~0xff000000;	/* Clock mask */
	- 		iomem->cmxfcr |= 0x37000000;	/* Clock route */
	+ 		imm->cmxfcr &= ~0xff000000;	/* Clock mask */
	+ 		imm->cmxfcr |= 0x37000000;	/* Clock route */
	  		break;
	  
	  	case 1:
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/etherfcc.c:546,595 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/etherfcc.c:546,595
	  		/* Step 1 (Section 28.9), write the parallel ports */
	  		ctlr->pmdio = 0x00400000;
	  		ctlr->pmdck = 0x00200000;
	- 		iomem->port[1].pdir &= ~B2dir0;
	- 		iomem->port[1].pdir |= B2dir1;
	- 		iomem->port[1].psor &= ~B2psor0;
	- 		iomem->port[1].psor |= B2psor1;
	- 		iomem->port[1].ppar |= (B2dir0 | B2dir1);
	+ 		imm->port[1].pdir &= ~B2dir0;
	+ 		imm->port[1].pdir |= B2dir1;
	+ 		imm->port[1].psor &= ~B2psor0;
	+ 		imm->port[1].psor |= B2psor1;
	+ 		imm->port[1].ppar |= (B2dir0 | B2dir1);
	  		/* Step 2, Port C clocks */
	- 		iomem->port[2].psor &= ~0x00003000;
	- 		iomem->port[2].pdir &= ~0x00003000;
	- 		iomem->port[2].ppar |= 0x00003000;
	+ 		imm->port[2].psor &= ~0x00003000;
	+ 		imm->port[2].pdir &= ~0x00003000;
	+ 		imm->port[2].ppar |= 0x00003000;
	  
	- 		iomem->port[2].pdat |= (ctlr->pmdio | ctlr->pmdck);
	- 		iomem->port[2].podr |= ctlr->pmdio;
	- 		iomem->port[2].pdir |= (ctlr->pmdio | ctlr->pmdck);
	- 		iomem->port[2].ppar &= ~(ctlr->pmdio | ctlr->pmdck);
	+ 		imm->port[2].pdat |= (ctlr->pmdio | ctlr->pmdck);
	+ 		imm->port[2].podr |= ctlr->pmdio;
	+ 		imm->port[2].pdir |= (ctlr->pmdio | ctlr->pmdck);
	+ 		imm->port[2].ppar &= ~(ctlr->pmdio | ctlr->pmdck);
	  		eieio();
	  		/* Step 3, Serial Interface clock routing */
	- 		iomem->cmxfcr &= ~0x00ff0000;
	- 		iomem->cmxfcr |= 0x00250000;
	+ 		imm->cmxfcr &= ~0x00ff0000;
	+ 		imm->cmxfcr |= 0x00250000;
	  		break;
	  
	  	case 2:
	  		/* Step 1 (Section 28.9), write the parallel ports */
	- 		iomem->port[1].pdir &= ~B3dir0;
	- 		iomem->port[1].pdir |= B3dir1;
	- 		iomem->port[1].psor &= ~B3psor0;
	- 		iomem->port[1].psor |= B3psor1;
	- 		iomem->port[1].ppar |= (B3dir0 | B3dir1);
	+ 		imm->port[1].pdir &= ~B3dir0;
	+ 		imm->port[1].pdir |= B3dir1;
	+ 		imm->port[1].psor &= ~B3psor0;
	+ 		imm->port[1].psor |= B3psor1;
	+ 		imm->port[1].ppar |= (B3dir0 | B3dir1);
	  		/* Step 2, Port C clocks */
	- 		iomem->port[2].psor &= ~0x0000c000;
	- 		iomem->port[2].pdir &= ~0x0000c000;
	- 		iomem->port[2].ppar |= 0x0000c000;
	- 		iomem->port[3].pdat |= (ctlr->pmdio | ctlr->pmdck);
	- 		iomem->port[3].podr |= ctlr->pmdio;
	- 		iomem->port[3].pdir |= (ctlr->pmdio | ctlr->pmdck);
	- 		iomem->port[3].ppar &= ~(ctlr->pmdio | ctlr->pmdck);
	+ 		imm->port[2].psor &= ~0x0000c000;
	+ 		imm->port[2].pdir &= ~0x0000c000;
	+ 		imm->port[2].ppar |= 0x0000c000;
	+ 		imm->port[3].pdat |= (ctlr->pmdio | ctlr->pmdck);
	+ 		imm->port[3].podr |= ctlr->pmdio;
	+ 		imm->port[3].pdir |= (ctlr->pmdio | ctlr->pmdck);
	+ 		imm->port[3].ppar &= ~(ctlr->pmdio | ctlr->pmdck);
	  		eieio();
	  		/* Step 3, Serial Interface clock routing */
	- 		iomem->cmxfcr &= ~0x0000ff00;
	- 		iomem->cmxfcr |= 0x00003700;
	+ 		imm->cmxfcr &= ~0x0000ff00;
	+ 		imm->cmxfcr |= 0x00003700;
	  		break;
	  	}
	  	iopunlock();
	  
	- 	p = (Etherparam*)(m->imap->prmfcc + ctlr->port);
	+ 	p = (Etherparam*)(m->immr->prmfcc + ctlr->port);
	  	memset(p, 0, sizeof(Etherparam));
	  
	  	/* Step 4 */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/etherfcc.c:623,632 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/etherfcc.c:623,632
	  		p->paddr[2-i/2] = (ea[i+1]<<8)|ea[i];
	  
	  	/* Step 7, initialize parameter ram, configuration-dependent values */
	- 	p->riptr = m->imap->fccextra[ctlr->port].ri - (uchar*)INTMEM;
	- 	p->tiptr = m->imap->fccextra[ctlr->port].ti - (uchar*)INTMEM;
	- 	p->padptr = m->imap->fccextra[ctlr->port].pad - (uchar*)INTMEM;
	- 	memset(m->imap->fccextra[ctlr->port].pad, 0x88, 0x20);
	+ 	p->riptr = m->immr->fccextra[ctlr->port].ri - (uchar*)IMMR;
	+ 	p->tiptr = m->immr->fccextra[ctlr->port].ti - (uchar*)IMMR;
	+ 	p->padptr = m->immr->fccextra[ctlr->port].pad - (uchar*)IMMR;
	+ 	memset(m->immr->fccextra[ctlr->port].pad, 0x88, 0x20);
	  
	  	/* Step 8, clear out events */
	  	fcc->fcce = ~0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/etherfcc.c:690,696 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/etherfcc.c:690,696
	  	}
	  	ether->irq = fccirq[ether->port];
	  	ether->tbdf = BusPPC;
	- 	fcc = iomem->fcc + ether->port;
	+ 	fcc = imm->fcc + ether->port;
	  
	  	ctlr = malloc(sizeof(*ctlr));
	  	ether->ctlr = ctlr;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/etherfcc.c:786,792 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/etherfcc.c:786,792
	  	 */
	  
	  	ctlr = mii->ctlr;
	- 	port = iomem->port + 3;
	+ 	port = imm->port + 3;
	  	cmd = MDIwrite | (pa<<(5+2+16))| (ra<<(2+16)) | (data & 0xffff);
	  
	  	x = splhi();
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/etherfcc.c:815,821 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/etherfcc.c:815,821
	  	Ctlr *ctlr;
	  
	  	ctlr = mii->ctlr;
	- 	port = iomem->port + 3;
	+ 	port = imm->port + 3;
	  
	  	cmd = MDIread | pa<<(5+2+16) | ra<<(2+16);
	  
 [rsc] --rw-rw-r-- M 451989 presotto sys 9075 Nov  6 10:15 sys/src/9/ppc/main.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/main.c:330,342 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/main.c:330,342
	  	pa = PGROUND(PADDR(end));
	  
	  	/* Blast Board specific */
	- 	conf.npage0 = (MEM1SIZE - pa)/BY2PG;
	- 	conf.base0 = pa;
	+ 	conf.mem[0].npage = (MEM1SIZE - pa)/BY2PG;
	+ 	conf.mem[0].base = pa;
	  	
	- 	conf.npage1 = MEM2SIZE/BY2PG;
	- 	conf.base1 = MEM2BASE;
	+ 	conf.mem[1].npage = MEM2SIZE/BY2PG;
	+ 	conf.mem[1].base = MEM2BASE;
	  
	- 	conf.npage = conf.npage0 + conf.npage1;
	+ 	conf.npage = conf.mem[0].npage + conf.mem[1].npage;
	  
	  	conf.nmach = 1;
	  	conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5;
 [rsc] --rw-rw-r-- M 451989 presotto sys 17067 Nov  6 10:15 sys/src/9/ppc/trap.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/trap.c:9,15 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/trap.c:9,15
	  #include	<trace.h>
	  
	  static Lock vctllock;
	- static Vctl *vctl[256];
	+ Vctl *vctl[256];
	  
	  void
	  intrenable(int irq, void (*f)(Ureg*, void*), void* a, char *name)
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/trap.c:56,63 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/trap.c:56,68
	  		  ((*pv)->irq != irq || (*pv)->f != f || (*pv)->a != a ||
	  		   strcmp((*pv)->name, name)))
	  		pv = &((*pv)->next);
	- 	assert(*pv);
	  
	+ 	if(*pv == nil){
	+ 		print("intrdisable: irq %d not found\n", irq);
	+ 		iunlock(&vctllock);
	+ 		return;
	+ 	}
	+ 
	  	v = *pv;
	  	*pv = (*pv)->next;	/* Link out the entry */
	  	
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/trap.c:154,159 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/trap.c:159,165
	  {
	  	int ecode, user;
	  	char buf[ERRMAX], *s;
	+ 	extern FPsave initfp;
	  
	  	ecode = (ureg->cause >> 8) & 0xff;
	  	user = (ureg->srr1 & MSR_PR) != 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/trap.c:379,471 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/trap.c:385,390
	  		vp[n] = 0x4e800021;		/* BL (LR) */
	  	}else
	  		vp[n] = (18<<26)|(pa&0x3FFFFFC)|3;	/* bla */
	- }
	- 
	- int intrstack[5];
	- uvlong intrtime[5];
	- vlong lastoffset;
	- int inintr;
	- int nintr[10];
	- int nintro;
	- int dblintr[64];
	- ulong thisto[32];
	- ulong thistoo;
	- vlong vnot[64];
	- ulong vnon[64];
	- 
	- void
	- dumpvno(void)
	- {
	- 	int i;
	- 
	- 	for(i = 0; i < nelem(vnon); i++){
	- 		if(vnon[i])
	- 			print("%d	%lld	%lud\n", i, vnot[i], vnon[i]);
	- 		vnot[i] = 0;
	- 		vnon[i] = 0;
	- 	}
	- 	for(i = 0; i < nelem(thisto); i++){
	- 		if(thisto[i]) print("%d	%lud\n", i, thisto[i]);
	- 		thisto[i] = 0;
	- 	}
	- 	if(thistoo) print("ovl	%lud\n", thistoo);
	- 	thistoo = 0;
	- }
	- 
	- void
	- intr(Ureg *ureg)
	- {
	- 	int vno, pvno, i;
	- 	Vctl *ctl, *v;
	- 	void (*pt)(Proc*, int, vlong);
	- 	uvlong tt, x;
	- 
	- 	cycles(&tt);
	- 	pt = proctrace;
	- 	pvno = -1;
	- 	for(i = 0; i < 64; i++){
	- 		vno = intvec();
	- 		if(vno == 0)
	- 			break;
	- 		cycles(&x);
	- 		vnot[vno] -= x;
	- 		if(vno == pvno)
	- 			dblintr[vno]++;
	- 		pvno = vno;
	- 		if(pt && up && up->trace)
	- 			pt(up, (vno << 16) | SInts, 0);
	- 	
	- 		if(vno > nelem(vctl) || (ctl = vctl[vno]) == 0) {
	- 			iprint("spurious intr %d\n", vno);
	- 			return;
	- 		}
	- 
	- 		for(v = ctl; v != nil; v = v->next)
	- 			if(v->f)
	- 				v->f(ureg, v->a);
	- 
	- 		intend(vno);	/* reenable the interrupt */
	- 
	- 		if(pt && up && up->trace)
	- 			pt(up, (vno << 16) | SInte, 0);
	- 		cycles(&x);
	- 		vnot[vno] += x;
	- 		vnon[vno]++;
	- 	}
	- 	if(i < nelem(nintr))
	- 		nintr[i]++;
	- 	else
	- 		nintro++;
	- 	cycles(&x);
	- 	tt = x - tt;
	- 	i = tt / 3600;	 /* 100 microseconds units */
	- 	if(i < nelem(thisto))
	- 		thisto[i]++;
	- 	else
	- 		thistoo++;
	- 
	- 	if(up)
	- 		preempted();
	  }
	  
	  char*
 [rsc] --rw-rw-r-- M 451989 presotto sys 9764 Nov  6 10:16 sys/src/9/ppc/uartsmc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:4,11 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:4,12
	  #include "dat.h"
	  #include "fns.h"
	  #include "io.h"
	- #include "m8260.h"
	+ #include "imm.h"
	  #include "../port/error.h"
	+ #include "../ppc/uartsmc.h"
	  
	  /*
	   * PowerPC 8260 SMC UART
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:12,19 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:13,18
	   */
	  
	  enum {
	- 	Nuart	= 1,		/* Number of SMC Uarts */
	- 
	  	/* SMC Mode Registers */
	  	Clen		= 0x7800,	/* Character length */
	  	Sl		= 0x0400,	/* Stop length, 0: one stop bit, 1: two */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:36,44 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:35,43
	  	BDContin=	1<<9,
	  	BDIdle=		1<<8,
	  	BDPreamble=	1<<8,
	- 	BDBreak=		1<<5,
	+ 	BDBreak=	1<<5,
	  	BDFrame=	1<<4,
	- 	BDParity=		1<<3,
	+ 	BDParity=	1<<3,
	  	BDOverrun=	1<<1,
	  
	  	/* Tx and Rx buffer sizes (32 bytes) */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:71,96 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:70,81
	  */
	  };
	  
	- typedef struct UartData UartData;
	- struct UartData
	- {
	- 	int		smcno;	/* smc number: 0 or 1 */
	- 	SMC		*smc;
	- 	Uartsmc	*usmc;
	- 	char		*rxbuf;
	- 	char		*txbuf;
	- 	BD*		rxb;
	- 	BD*		txb;
	- 	int		initialized;
	- 	int		enabled;
	- } uartdata[Nuart];
	- 
	  int uartinited = 0;
	  
	  static void smcinterrupt(Ureg*, void*);
	  static void smcputc(Uart *uart, int c);
	  
	- static int
	+ int
	  baudgen(int baud)
	  {
	  	int d;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:111,117 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:96,102
	  	return smcuart;
	  }
	  
	- static void
	+ void
	  smcinit(Uart *uart)
	  {
	  	Uartsmc *p;
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:125,136 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:110,120
	  	if (ud->initialized)
	  		return;
	  
	- 	/* magic addresses */
	- 	p = m->imap->uartsmc + ud->smcno;
	- 	smc = iomem->smc + ud->smcno;	/* SMC1 */
	- 	ud->smc = smc;
	- 	ud->usmc = p;
	+ 	smcsetup(uart);	/* Steps 1 through 4, PPC-dependent */
	+ 	p = ud->usmc;
	+ 	smc = ud->smc;
	  
	+ 	/* step 5: set up buffer descriptors */
	  	/* setup my uart structure */
	  	if (ud->rxb == nil)
	  		ud->rxb = bdalloc(1);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:137,180 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:121,129
	  	if (ud->txb == nil)
	  		ud->txb = bdalloc(1);
	  
	- 	/* step 0: disable rx/tx */
	- 	smc->smcmr &= ~3;
	+ 	p->rbase = ((ulong)ud->rxb) - (ulong)IMMR;
	+ 	p->tbase = ((ulong)ud->txb) - (ulong)IMMR;
	  
	- 	ioplock();
	- 
	- 	/* step 1, Using Port D */
	- 	if (ud->smcno != 0)
	- 		panic("Don't know how to set Port D bits");
	- 	iomem->port[SMC1PORT].ppar |= SMRXD1|SMTXD1;
	- 	iomem->port[SMC1PORT].pdir |= SMTXD1;
	- 	iomem->port[SMC1PORT].pdir &= ~SMRXD1;
	- 	iomem->port[SMC1PORT].psor &= ~(SMRXD1|SMTXD1);
	- 
	- 	/* step 2: set up brgc1 */
	- 	iomem->brgc[ud->smcno]  = baudgen(uart->baud) | 0x10000;
	- 
	- 	/* step 3: route clock to SMC1 */
	- 	iomem->cmxsmr &= (ud->smcno == 0) ? ~0xb0 : ~0xb;	/* clear smcx and smcxcs */
	- 
	- 	iopunlock();
	- 
	- 	/* step 4: assign a pointer to the SMCparameter RAM */
	- 	m->imap->param[ud->smcno].smcbase = (ulong)p - INTMEM;
	- 
	- 	/* step 5: set up buffer descriptors */
	- 	p->rbase = ((ulong)ud->rxb) - (ulong)INTMEM;
	- 	p->tbase = ((ulong)ud->txb) - (ulong)INTMEM;
	- 
	- 	/* step 6: issue command to CP */
	- 	if (ud->smcno == 0)
	- 		cpmop(InitRxTx, SMC1ID, 0);
	- 	else
	- 		cpmop(InitRxTx, SMC2ID, 0);
	- 
	- 	/* step 7: protocol parameters */
	- 	p->rfcr = 0x30;
	- 	p->tfcr = 0x30;
	- 
	  	/* step 8: receive buffer size */
	  	p->mrblr = Rxsize;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:206,213 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:155,160
	  	/* 
	  	 * step 15: enable interrupts (done later)
	  	 * smc->smcm = ce_Brke | ce_Br | ce_Bsy | ce_Txb | ce_Rxb;
	- 
	- 	 * intrenable(4 + ud->smcno, smcinterrupt, up, 0, uart->name);
	  	 */
	  
	  	/* step 17: set parity, no of bits, UART mode, ... */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:261,267 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:208,214
	  	smc->smce = ce_Brke | ce_Br | ce_Bsy | ce_Txb | ce_Rxb;
	  	/* enable interrupts */
	  	smc->smcm = ce_Brke | ce_Br | ce_Bsy | ce_Txb | ce_Rxb;
	- 	intrenable(4 + ud->smcno, smcinterrupt, uart, uart->name);
	+ 	intrenable(VecSMC1 + ud->smcno, smcinterrupt, uart, uart->name);
	  	ud->enabled = 1;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:426,433 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:373,380
	  		if(uart->freq == 0 || baud <= 0)
	  			return -1;
	  	
	- 		i = sp - iomem->smc;
	- 		iomem->brgc[i] = (((m->brghz >> 4) / baud) << 1) | 0x00010000;
	+ 		i = sp - imm->smc;
	+ 		imm->brgc[i] = (((m->brghz >> 4) / baud) << 1) | 0x00010000;
	  	}
	  	uart->baud = baud;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/ppc/uartsmc.c:636,669 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/ppc/uartsmc.c:583,585
	  	consuart = uart;
	  	uart->console = 1;
	  } 
	- 
	- void
	- dbgputc(int c)
	- {
	- 	Uartsmc *su;
	- 	BD *tbdf;
	- 	Imap *imap;
	- 	char *addr;
	- 
	- 	/* Should work as long as Imap is mapped at 0xf0000000 (INTMEM) */
	- 
	- 	imap = (Imap*)INTMEM;
	- 	su = (Uartsmc *)(INTMEM | imap->param[0].smcbase);
	- 	tbdf = (BD *)(INTMEM | su->tbase);
	- 
	- 	/* Wait for last character to go.
	- 	*/
	- 	while (tbdf->status & BDReady)
	- 		;
	- 
	- 	addr = KADDR(tbdf->addr);
	- 	*addr = c;
	- 	tbdf->length = 1;
	- 	sync();
	- 	tbdf->status |= BDReady;
	- 
	- 	while (tbdf->status & BDReady)
	- 		;
	- 
	- 	delay(300);
	- }
 [rsc] --rw-rw-r-- M 451989 glenda sys 3037 Nov  6 11:14 sys/src/9/pc/apbootstrap.s
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/apbootstrap.s:1,3 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/apbootstrap.s:1,13
	+ /*
	+  * Start an Application Processor. This must be placed on a 4KB boundary
	+  * somewhere in the 1st MB of conventional memory (APBOOTSTRAP). However,
	+  * due to some shortcuts below it's restricted further to within the 1st
	+  * 64KB. The AP starts in real-mode, with
	+  *   CS selector set to the startup memory address/16;
	+  *   CS base set to startup memory address;
	+  *   CS limit set to 64KB;
	+  *   CPL and IP set to 0.
	+  */
	  #include "mem.h"
	  
	  #define NOP		BYTE $0x90		/* NOP */
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/apbootstrap.s:23,38 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/apbootstrap.s:33,38
	  #define PDO(a)		(((((a))>>22) & 0x03FF)<<2)
	  #define PTO(a)		(((((a))>>12) & 0x03FF)<<2)
	  
	- /*
	-  * Start an Application Processor. This must be placed on a 4KB boundary
	-  * somewhere in the 1st MB of conventional memory (APBOOTSTRAP). However,
	-  * due to some shortcuts below it's restricted further to within the 1st
	-  * 64KB. The AP starts in real-mode, with
	-  *   CS selector set to the startup memory address/16;
	-  *   CS base set to startup memory address;
	-  *   CS limit set to 64KB;
	-  *   CPL and IP set to 0.
	-  */
	  TEXT apbootstrap(SB), $0
	  	FARJUMP16(0, _apbootstrap(SB))
	  TEXT _apvector(SB), $0				/* address APBOOTSTRAP+0x08 */
 [rsc] --rw-rw-r-- M 451989 glenda sys 7133 Nov  6 11:09 sys/src/9/pc/sdscsi.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/sdscsi.c:372,394 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/sdscsi.c:372,374
	  	return rlen;
	  }
	  
	- SDev*
	- scsiid(SDev* sdev, SDifc* ifc)
	- {
	- 	char name[32];
	- 	static char idno[16] = "0123456789abcdef";
	- 	static char *p = idno;
	- 
	- 	while(sdev){
	- 		if(sdev->ifc == ifc){
	- 			sdev->idno = *p++;
	- 			snprint(name, sizeof(name), "sd%c", sdev->idno);
	- 			kstrdup(&sdev->name, name);
	- 			if(p >= &idno[sizeof(idno)])
	- 				break;
	- 		}
	- 		sdev = sdev->next;
	- 	}
	- 
	- 	return nil;
	- }
 [rsc] --rw-rw-r-- M 451989 rsc sys 2658 Nov  6 11:30 sys/src/9/pc/realmode.c
 [rsc] --rw-rw-r-- M 451989 glenda sys 15159 Nov  6 12:35 sys/src/9/port/sysproc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/sysproc.c:259,265 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/sysproc.c:259,265
	  		text = l2be(exec.text);
	  		entry = l2be(exec.entry);
	  		if(n==sizeof(Exec) && (magic == AOUT_MAGIC)){
	- 			if((text&KZERO) == KZERO
	+ 			if(text >= USTKTOP-UTZERO
	  			|| entry < UTZERO+sizeof(Exec)
	  			|| entry >= UTZERO+sizeof(Exec)+text)
	  				error(Ebadexec);
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/sysproc.c:298,304 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/sysproc.c:298,304
	  	d = (t + data + (BY2PG-1)) & ~(BY2PG-1);
	  	bssend = t + data + bss;
	  	b = (bssend + (BY2PG-1)) & ~(BY2PG-1);
	- 	if(((t|d|b) & KZERO) == KZERO)
	+ 	if(t >= KZERO || d >= KZERO || b >= KZERO)
	  		error(Ebadexec);
	  
	  	/*
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/sysproc.c:807,819 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/sysproc.c:807,818
	  long
	  sysrendezvous(ulong *arg)
	  {
	- 	ulong tag;
	- 	ulong val;
	+ 	uintptr tag, val;
	  	Proc *p, **l;
	  
	  	tag = arg[0];
	  	l = &REND(up->rgrp, tag);
	- 	up->rendval = ~0UL;
	+ 	up->rendval = ~(uintptr)0;
	  
	  	lock(up->rgrp);
	  	for(p = *l; p; p = p->rendhash) {
 [rsc] --rw-rw-r-- M 451989 glenda sys 3580 Nov  6 11:34 sys/src/9/pc/mkfile
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mkfile:1,11 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mkfile:1,18
	  CONF=pc
	  CONFLIST=pc pccpu pcf pccpuf pcdisk pcauth
	- CRAPLIST=pccd pccpud pccpusape pcext pcf pcflop pcglenda pcgr pclml pcmartha pcsape pcblast
	+ CRAPLIST=pccd pcflop pcmartha
	+ EXTRACOPIES=
	+ #EXTRACOPIES=lookout boundary	# copy to these servers on install
	  
	  objtype=386
	  </$objtype/mkfile
	  p=9
	  
	+ # must match mem.h
	+ 
	+ APBOOTSTRAP=0xF0003000
	+ KTZERO=0xF0100020
	+ 
	  DEVS=`{rc ../port/mkdevlist $CONF}
	  
	  PORT=\
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mkfile:16,24 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mkfile:23,31
	  	cache.$O\
	  	chan.$O\
	  	dev.$O\
	+ 	edf.$O\
	  	fault.$O\
	  	latin1.$O\
	- 	edf.$O\
	  	page.$O\
	  	parse.$O\
	  	pgrp.$O\
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mkfile:27,32 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mkfile:34,40
	  	proc.$O\
	  	qio.$O\
	  	qlock.$O\
	+ 	rdb.$O\
	  	rebootcmd.$O\
	  	segment.$O\
	  	swap.$O\
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mkfile:47,53 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mkfile:55,60
	  	memory.$O\
	  	mmu.$O\
	  	random.$O\
	- 	rdb.$O\
	  	trap.$O\
	  	$CONF.root.$O\
	  	$CONF.rootc.$O\
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mkfile:67,81 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mkfile:74,89
	  
	  $p$CONF:	$CONF.c $OBJ $LIB
	  	$CC $CFLAGS '-DKERNDATE='`{date -n} $CONF.c
	- 	$LD -o $target -T0x80100020 -l $OBJ $CONF.$O $LIB
	+ 	$LD -o $target -T$KTZERO -l $OBJ $CONF.$O $LIB
	  	size $target
	  
	- $p$CONF.gz: $p$CONF
	- 	strip < $p$CONF | gzip -9 > $p$CONF.gz
	+ $p$CONF.gz:	$p$CONF
	+ 	strip -o /fd/1 $p$CONF | gzip -9 > $p$CONF.gz
	  
	- install:V: $p$CONF $p$CONF.gz
	+ install:V:	$p$CONF $p$CONF.gz
	  	cp $p$CONF $p$CONF.gz /$objtype/
	- 	# import lookout / /n/lookout && cp $p$CONF $p$CONF.gz /n/lookout/$objtype/
	+ 	for(i in $EXTRACOPIES)
	+ 		import $i / /n/$i && cp $p$CONF $p$CONF.gz /n/$i/$objtype/
	  
	  <../boot/bootmkfile
	  <../port/portmkfile
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mkfile:90,109 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mkfile:98,118
	  $SDEV:				../port/sd.h
	  sd53c8xx.$O:			sd53c8xx.i
	  main.$O:			init.h reboot.h
	- wavelan.$O:	wavelan.c ../pc/wavelan.c ../pc/wavelan.h
	- etherwavelan.$O:	etherwavelan.c  ../pc/wavelan.h
	- devusb.$O usbuhci.$O usbohci.$O:	usb.h
	- trap.$O:	/sys/include/tos.h
	+ wavelan.$O:			wavelan.c ../pc/wavelan.c ../pc/wavelan.h
	+ etherwavelan.$O:		etherwavelan.c ../pc/wavelan.h
	+ devusb.$O usbuhci.$O usbohci.$O: usb.h
	+ trap.$O:			/sys/include/tos.h
	  
	  sd53c8xx.i:	sd53c8xx.n
	  	aux/na $prereq > $target
	  
	- init.h:	../port/initcode.c init9.c
	+ init.h:		../port/initcode.c init9.c
	  	$CC ../port/initcode.c
	  	$CC init9.c
	  	$LD -l -R1 -o init.out init9.$O initcode.$O /386/lib/libc.a
	+ 	strip init.out
	  	{echo 'uchar initcode[]={'
	- 	 strip < init.out | xd -1x |
	+ 	 cat init.out | xd -1x |
	  		sed -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
	  	 echo '};'} > init.h
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mkfile:117,123 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mkfile:126,132
	  
	  apbootstrap.h:	apbootstrap.s mem.h
	  	$AS $prereq
	- 	$LD -o apbootstrap.out -T0x80001000 -R4 -l -s apbootstrap.$O
	+ 	$LD -o apbootstrap.out -T$APBOOTSTRAP -R4 -l -s apbootstrap.$O
	  	{echo 'uchar apbootstrap[]={'
	  	 xd -1x apbootstrap.out |
	  		sed -e '1,2d' -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mkfile:124,130 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mkfile:133,139
	  	 echo '};'} > $target
	  
	  acid:V:
	- 	8c -a -w -I. ../port/qio.c>acid
	+ 	8c -a -w -I. i8253.c>acid
	  
	  %.checkether:VQ:
	  	for (i in ether*.c){
	/n/sourcesdump/2005/1106/plan9/sys/src/9/pc/mkfile:148,151 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/pc/mkfile:157,172
	  		mk $i.$j
	  
	  %.clean:V:
	- 	rm -f $stem.c [9bz]$stem [9bz]$stem.gz boot$stem.*
	+ 	rm -f $stem.c [9bz]$stem [9bz]$stem.gz boot$stem.* reboot.h apbootstrap.h init.h
	+ 
	+ # testing
	+ 9load:D: /usr/rsc/boot/$O.load 9pcload
	+ 	cat $prereq >$target
	+ 
	+ 9load.flp: 9load
	+ 	disk/format -b /386/pbs -df $target $prereq
	+ 
	+ $p$CONF.flp: /386/9load plan9.ini $p$CONF.gz
	+ 	disk/format -b /386/pbs -df $target $prereq
	+ 
	+ 
 [rsc] --rw-rw-r-- M 451989 glenda sys 33663 Nov  6 12:38 sys/src/9/port/chan.c
	/n/sourcesdump/2005/1106/plan9/sys/src/9/port/chan.c:1600,1606 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/9/port/chan.c:1600,1607
	  	Rune r;
	  
	  	name = aname;
	- 	if(((ulong)name & KZERO) != KZERO){
	+ 	if((ulong)name < KZERO){
	+ 		validaddr((ulong)name, 1, 0);
	  		if(!dup)
	  			print("warning: validname called from %lux with user pointer", pc);
	  		p = name;
 [rsc] --rw-rw-r-- M 451989 glenda sys 13722 Nov  6 12:35 sys/src/9/port/segment.c
 [rsc] --rw-rw-r-- M 451989 glenda sys 15159 Nov  6 12:35 sys/src/9/port/sysproc.c
 [rsc] --rw-rw-r-- M 451989 glenda sys 1446 Nov  6 12:59 sys/src/9/pc/pcdisk
 [rsc] --rw-rw-r-- M 451989 presotto sys 1504 Nov  6 12:59 sys/src/9/pc/pcf
 [rsc] --rw-rw-r-- M 451989 presotto sys 1486 Nov  6 12:59 sys/src/9/pc/pccpuf
 [rsc] --rw-rw-r-- M 451989 rsc sys 1473 Nov  6 12:59 sys/src/9/pc/pcflop
 [rsc] --rw-rw-r-- M 451989 glenda sys 21180 Nov  6 14:44 sys/src/9/pc/trap.c
 [rsc] --rw-rw-r-- M 451989 glenda sys 19739 Nov  6 20:17 sys/src/9/pc/mmu.c
 [rsc] --rw-rw-r-- M 451989 glenda sys 17157 Nov  6 20:17 sys/src/9/pc/mp.c

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 8586 Nov  6 09:58 sys/include/mach.h
	/n/sourcesdump/2005/1106/plan9/sys/include/mach.h:119,127 - 
	/n/sourcesdump/2005/1107/plan9/sys/include/mach.h:119,127
	  		int	fd;		/* file descriptor */
	  		int	inuse;		/* in use - not in use */
	  		int	cache;		/* should cache reads? */
	- 		ulong	b;		/* base */
	- 		ulong	e;		/* end */
	- 		ulong	f;		/* offset within file */
	+ 		uvlong	b;		/* base */
	+ 		uvlong	e;		/* end */
	+ 		vlong	f;		/* offset within file */
	  	} seg[1];			/* actually n of these */
	  };
	  
	/n/sourcesdump/2005/1106/plan9/sys/include/mach.h:169,176 - 
	/n/sourcesdump/2005/1107/plan9/sys/include/mach.h:169,176
	  	char	*name;
	  	int	mtype;			/* machine type code */
	  	Reglist *reglist;		/* register set */
	- 	ulong	regsize;		/* sizeof registers in bytes*/
	- 	ulong	fpregsize;		/* sizeof fp registers in bytes*/
	+ 	long	regsize;		/* sizeof registers in bytes */
	+ 	long	fpregsize;		/* sizeof fp registers in bytes */
	  	char	*pc;			/* pc name */
	  	char	*sp;			/* sp name */
	  	char	*link;			/* link register name */
	/n/sourcesdump/2005/1106/plan9/sys/include/mach.h:179,184 - 
	/n/sourcesdump/2005/1107/plan9/sys/include/mach.h:179,185
	  	int	pgsize;			/* page size */
	  	uvlong	kbase;			/* kernel base address */
	  	uvlong	ktmask;			/* ktzero = kbase & ~ktmask */
	+ 	uvlong	utop;			/* user stack top */
	  	int	pcquant;		/* quantization of pc */
	  	int	szaddr;			/* sizeof(void*) */
	  	int	szreg;			/* sizeof(register) */
	/n/sourcesdump/2005/1106/plan9/sys/include/mach.h:188,213 - 
	/n/sourcesdump/2005/1107/plan9/sys/include/mach.h:189,214
	  
	  extern	Mach	*mach;			/* Current machine */
	  
	- typedef vlong	(*Rgetter)(Map*, char*);
	- typedef	void	(*Tracer)(Map*, ulong, ulong, Symbol*);
	+ typedef uvlong	(*Rgetter)(Map*, char*);
	+ typedef	void	(*Tracer)(Map*, uvlong, uvlong, Symbol*);
	  
	  struct	Machdata {		/* Machine-dependent debugger support */
	  	uchar	bpinst[4];			/* break point instr. */
	  	short	bpsize;				/* size of break point instr. */
	  
	- 	ushort	(*swab)(ushort);		/* short to local byte order */
	- 	long	(*swal)(long);			/* long to local byte order */
	- 	vlong	(*swav)(vlong);			/* vlong to local byte order */
	- 	int	(*ctrace)(Map*, ulong, ulong, ulong, Tracer); /* C traceback */
	- 	ulong	(*findframe)(Map*, ulong, ulong, ulong, ulong);/* frame finder */
	+ 	ushort	(*swab)(ushort);		/* ushort to local byte order */
	+ 	ulong	(*swal)(ulong);			/* ulong to local byte order */
	+ 	uvlong	(*swav)(uvlong);		/* uvlong to local byte order */
	+ 	int	(*ctrace)(Map*, uvlong, uvlong, uvlong, Tracer); /* C traceback */
	+ 	uvlong	(*findframe)(Map*, uvlong, uvlong, uvlong, uvlong);/* frame finder */
	  	char*	(*excep)(Map*, Rgetter);	/* last exception */
	- 	ulong	(*bpfix)(ulong);		/* breakpoint fixup */
	+ 	ulong	(*bpfix)(uvlong);		/* breakpoint fixup */
	  	int	(*sftos)(char*, int, void*);	/* single precision float */
	  	int	(*dftos)(char*, int, void*);	/* double precision float */
	- 	int	(*foll)(Map*, ulong, Rgetter, ulong*);	/* follow set */
	- 	int	(*das)(Map*, ulong, char, char*, int);	/* symbolic disassembly */
	- 	int	(*hexinst)(Map*, ulong, char*, int); 	/* hex disassembly */
	- 	int	(*instsize)(Map*, ulong);	/* instruction size */
	+ 	int	(*foll)(Map*, uvlong, Rgetter, uvlong*);/* follow set */
	+ 	int	(*das)(Map*, uvlong, char, char*, int);	/* symbolic disassembly */
	+ 	int	(*hexinst)(Map*, uvlong, char*, int); 	/* hex disassembly */
	+ 	int	(*instsize)(Map*, uvlong);	/* instruction size */
	  };
	  
	  /*
	/n/sourcesdump/2005/1106/plan9/sys/include/mach.h:216,238 - 
	/n/sourcesdump/2005/1107/plan9/sys/include/mach.h:217,240
	  typedef struct Fhdr
	  {
	  	char	*name;		/* identifier of executable */
	- 	short	type;		/* file type - see codes above*/
	- 	short	hdrsz;		/* size of this header */
	+ 	uchar	type;		/* file type - see codes above*/
	+ 	uchar	hdrsz;		/* header size */
	+ 	uchar	spare[2];
	  	long	magic;		/* magic number */
	- 	long	txtaddr;	/* text address */
	- 	long	entry;		/* entry point */
	+ 	uvlong	txtaddr;	/* text address */
	+ 	vlong	txtoff;		/* start of text in file */
	+ 	uvlong	dataddr;	/* start of data segment */
	+ 	vlong	datoff;		/* offset to data seg in file */
	+ 	vlong	symoff;		/* offset of symbol table in file */
	+ 	uvlong	entry;		/* entry point */
	+ 	vlong	sppcoff;	/* offset of sp-pc table in file */
	+ 	vlong	lnpcoff;	/* offset of line number-pc table in file */
	  	long	txtsz;		/* text size */
	- 	long	txtoff;		/* start of text in file */
	- 	long	dataddr;	/* start of data segment */
	  	long	datsz;		/* size of data seg */
	- 	long	datoff;		/* offset to data seg in file */
	  	long	bsssz;		/* size of bss */
	  	long	symsz;		/* size of symbol table */
	- 	long	symoff;		/* offset of symbol table in file */
	  	long	sppcsz;		/* size of sp-pc table */
	- 	long	sppcoff;	/* offset of sp-pc table in file */
	  	long	lnpcsz;		/* size of line number-pc table */
	- 	long	lnpcoff;	/* size of line number-pc table */
	  } Fhdr;
	  
	  extern	int	asstype;	/* dissembler type - machdata.c */
	/n/sourcesdump/2005/1106/plan9/sys/include/mach.h:243,266 - 
	/n/sourcesdump/2005/1107/plan9/sys/include/mach.h:245,269
	  int		beieeesftos(char*, int, void*);
	  int		beieeedftos(char*, int, void*);
	  ushort		beswab(ushort);
	- long		beswal(long);
	- vlong		beswav(vlong);
	- int		cisctrace(Map*, ulong, ulong, ulong, Tracer);
	- ulong		ciscframe(Map*, ulong, ulong, ulong, ulong);
	+ ulong		beswal(ulong);
	+ uvlong		beswav(uvlong);
	+ uvlong		ciscframe(Map*, uvlong, uvlong, uvlong, uvlong);
	+ int		cisctrace(Map*, uvlong, uvlong, uvlong, Tracer);
	  int		crackhdr(int fd, Fhdr*);
	- long		file2pc(char*, ulong);
	+ uvlong		file2pc(char*, long);
	  int		fileelem(Sym**, uchar *, char*, int);
	- int		fileline(char*, int, ulong);
	+ long		fileline(char*, int, uvlong);
	  int		filesym(int, char*, int);
	  int		findlocal(Symbol*, char*, Symbol*);
	  int		findseg(Map*, char*);
	- int		findsym(long, int, Symbol *);
	- int		fnbound(long, ulong*);
	+ int		findsym(uvlong, int, Symbol *);
	+ int		fnbound(uvlong, uvlong*);
	  int		fpformat(Map*, Reglist*, char*, int, int);
	- int		get1(Map*, ulong, uchar*, int);
	- int		get2(Map*, ulong, ushort*);
	- int		get4(Map*, ulong, long*);
	- int		get8(Map*, ulong, vlong*);
	+ int		get1(Map*, uvlong, uchar*, int);
	+ int		get2(Map*, uvlong, ushort*);
	+ int		get4(Map*, uvlong, ulong*);
	+ int		get8(Map*, uvlong, uvlong*);
	+ int		geta(Map*, uvlong, uvlong*);
	  int		getauto(Symbol*, int, int, Symbol*);
	  Sym*		getsym(int);
	  int		globalsym(Symbol *, int);
	/n/sourcesdump/2005/1106/plan9/sys/include/mach.h:272,282 - 
	/n/sourcesdump/2005/1107/plan9/sys/include/mach.h:275,285
	  int		leieeesftos(char*, int, void*);
	  int		leieeedftos(char*, int, void*);
	  ushort		leswab(ushort);
	- long		leswal(long);
	- vlong		leswav(vlong);
	- long		line2addr(ulong, ulong, ulong);
	+ ulong		leswal(ulong);
	+ uvlong		leswav(uvlong);
	+ uvlong		line2addr(long, uvlong, uvlong);
	  Map*		loadmap(Map*, int, Fhdr*);
	- int		localaddr(Map*, char*, char*, long*, Rgetter);
	+ int		localaddr(Map*, char*, char*, uvlong*, Rgetter);
	  int		localsym(Symbol*, int);
	  int		lookup(char*, char*, Symbol*);
	  void		machbytype(int);
	/n/sourcesdump/2005/1106/plan9/sys/include/mach.h:285,304 - 
	/n/sourcesdump/2005/1107/plan9/sys/include/mach.h:288,308
	  Map*		newmap(Map*, int);
	  void		objtraverse(void(*)(Sym*, void*), void*);
	  int		objtype(Biobuf*, char**);
	- long		pc2sp(ulong);
	- long		pc2line(ulong);
	- int		put1(Map*, ulong, uchar*, int);
	- int		put2(Map*, ulong, ushort);
	- int		put4(Map*, ulong, long);
	- int		put8(Map*, ulong, vlong);
	- int		readar(Biobuf*, int, int, int);
	+ uvlong		pc2sp(uvlong);
	+ long		pc2line(uvlong);
	+ int		put1(Map*, uvlong, uchar*, int);
	+ int		put2(Map*, uvlong, ushort);
	+ int		put4(Map*, uvlong, ulong);
	+ int		put8(Map*, uvlong, uvlong);
	+ int		puta(Map*, uvlong, uvlong);
	+ int		readar(Biobuf*, int, vlong, int);
	  int		readobj(Biobuf*, int);
	- ulong		riscframe(Map*, ulong, ulong, ulong, ulong);
	- int		risctrace(Map*, ulong, ulong, ulong, Tracer);
	- int		setmap(Map*, int, ulong, ulong, ulong, char*);
	+ uvlong		riscframe(Map*, uvlong, uvlong, uvlong, uvlong);
	+ int		risctrace(Map*, uvlong, uvlong, uvlong, Tracer);
	+ int		setmap(Map*, int, uvlong, uvlong, vlong, char*);
	  Sym*		symbase(long*);
	  int		syminit(int, Fhdr*);
	- int		symoff(char*, int, long, int);
	- void		textseg(ulong, Fhdr*);
	+ int		symoff(char*, int, uvlong, int);
	+ void		textseg(uvlong, Fhdr*);
	  int		textsym(Symbol*, int);
	  void		unusemap(Map*, int);

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 4080 Nov  6 10:02 sys/src/libmach/0.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/0.c:130,137 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/0.c:130,138
	  	"setR30",	/* static base register name */
	  	0,		/* SB value */
	  	0x1000,		/* page size */
	- 	0xC0000000,	/* kernel base */
	- 	0x40000000,	/* kernel text mask */
	+ 	0xC0000000ULL,	/* kernel base */
	+ 	0x40000000ULL,	/* kernel text mask */
	+ 	0x7FFFFFFFULL,	/* user stack top */
	  	4,		/* quantization of pc */
	  	4,		/* szaddr */
	  	8,		/* szreg */
 [rsc] --rw-rw-r-- M 451989 glenda sys 2074 Nov  6 10:02 sys/src/libmach/2.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2.c:75,82 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2.c:75,83
	  	"a6base",	/* static base register name */
	  	0,		/* value */
	  	0x2000,		/* page size */
	- 	0x80000000,	/* kernel base */
	+ 	0x80000000ULL,	/* kernel base */
	  	0,		/* kernel text mask */
	+ 	0x7FFFFFFFULL,	/* user stack top */
	  	2,		/* quantization of pc */
	  	4,		/* szaddr */
	  	4,		/* szreg */
 [rsc] --rw-rw-r-- M 451989 glenda sys 61298 Nov  6 10:03 sys/src/libmach/2db.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:9,18 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:9,18
	  
	  static	char	*m68020excep(Map*, Rgetter);
	  
	- static	int	m68020foll(Map*, ulong, Rgetter, ulong*);
	- static	int	m68020inst(Map*, ulong, char, char*, int);
	- static	int	m68020das(Map*, ulong, char*, int);
	- static	int	m68020instlen(Map*, ulong);
	+ static	int	m68020foll(Map*, uvlong, Rgetter, uvlong*);
	+ static	int	m68020inst(Map*, uvlong, char, char*, int);
	+ static	int	m68020das(Map*, uvlong, char*, int);
	+ static	int	m68020instlen(Map*, uvlong);
	  
	  Machdata m68020mach =
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:95,103 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:95,104
	  {
	  	struct ftype *ft;
	  	int i, size, vec;
	- 	ulong efl[2], stktop;
	+ 	ulong efl[2];
	  	uchar *ef=(uchar*)efl;
	- 	long l;
	+ 	ulong l;
	+ 	uvlong stktop;
	  	short fvo;
	  
	  		/* The kernel proc pointer on a 68020 is always
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:112,118 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:113,120
	  	if ((l&0xfc000000) == 0x04000000)	/* if NeXT */
	  		size = 30*2;
	  	else
	- 		size = 46*2;		/* 68020 */
	+ 		size = 46*2;			/* 68020 */
	+ 	USED(size);
	  
	  	stktop = mach->kbase+mach->pgsize;
	  	for(i=3; i<100; i++){
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:145,151 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:147,153
	  static char *
	  m68020excep(Map *map, Rgetter rget)
	  {
	- 	ulong pc;
	+ 	uvlong pc;
	  	uchar buf[4];
	  
	  	if (m68020ufix(map) < 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:381,387 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:383,389
	  struct	inst
	  {
	  	int	n;		/* # bytes in instruction */
	- 	ulong	addr;		/* addr of start of instruction */
	+ 	uvlong	addr;		/* addr of start of instruction */
	  	ushort	raw[4+12];	/* longest instruction: 24 byte packed immediate */
	  	Operand	and[2];
	  	char	*end;		/* end of print buffer */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:906,912 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:908,914
	  }
	  
	  static int
	- getword(Inst *ip, long offset)
	+ getword(Inst *ip, uvlong offset)
	  {
	  	if (ip->n < nelem(ip->raw)) {
	  		if (get2(mymap, offset, &ip->raw[ip->n++]) > 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:1314,1320 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:1316,1322
	  plocal(Inst *ip, Operand *ap)
	  {
	  	int ret, offset;
	- 	long moved;
	+ 	uvlong moved;
	  	Symbol s;
	  
	  	offset = ap->disp;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:1979,1985 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:1981,1987
	  }
	  
	  static int
	- m68020instlen(Map *map, ulong pc)
	+ m68020instlen(Map *map, uvlong pc)
	  {
	  	Inst i;
	  	Optable *op;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:1994,2003 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:1996,2006
	  }
	  
	  static int
	- m68020foll(Map *map, ulong pc, Rgetter rget, ulong *foll)
	+ m68020foll(Map *map, uvlong pc, Rgetter rget, uvlong *foll)
	  {
	  	int j;
	  	Inst i;
	+ 	ulong l;
	  	Optable *op;
	  
	  	mymap = map;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:2019,2026 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:2022,2030
	  			foll[1] = pc+2+i.and[j].immediate;
	  			return 2;
	  		case STACK:	/* RTR, RTS, RTD */
	- 			if (get4(map, (*rget)(map, mach->sp), (long*) foll) < 0)
	+ 			if (get4(map, (*rget)(map, mach->sp), &l) < 0)
	  				return -1;
	+ 			*foll = l;
	  			return 1;
	  		default:
	  			break;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:2031,2037 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:2035,2041
	  }
	  
	  static int
	- m68020inst(Map *map, ulong pc, char modifier, char *buf, int n)
	+ m68020inst(Map *map, uvlong pc, char modifier, char *buf, int n)
	  {
	  	Inst i;
	  	Optable *op;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/2db.c:2057,2063 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/2db.c:2061,2067
	  }
	  
	  static int
	- m68020das(Map *map, ulong pc, char *buf, int n)
	+ m68020das(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Inst i;
	  	Optable *op;
 [rsc] --rw-rw-r-- M 451989 glenda sys 1553 Nov  6 10:03 sys/src/libmach/5.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5.c:53,60 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5.c:53,61
	  	"setR12",	/* static base register name */
	  	0,		/* static base register value */
	  	0x1000,		/* page size */
	- 	0xC0000000,	/* kernel base */
	+ 	0xC0000000ULL,	/* kernel base */
	  	0,		/* kernel text mask */
	+ 	0x7FFFFFFFULL,	/* user stack top */
	  	4,		/* quantization of pc */
	  	4,		/* szaddr */
	  	4,		/* szreg */
 [rsc] --rw-rw-r-- M 451989 glenda sys 21545 Nov  6 10:03 sys/src/libmach/5db.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:18,24 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:18,24
	  {
	  	Map	*map;
	  	ulong	w;
	- 	ulong	addr;
	+ 	uvlong	addr;
	  	uchar	op;			/* super opcode */
	  
	  	uchar	cond;			/* bits 28-31 */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:39,45 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:39,45
	  {
	  	char*	o;
	  	void	(*fmt)(Opcode*, Instr*);
	- 	ulong	(*foll)(Map*, Rgetter, Instr*, ulong);
	+ 	uvlong	(*foll)(Map*, Rgetter, Instr*, uvlong);
	  	char*	a;
	  };
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:51,60 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:51,60
	   */
	  
	  static	char	*armexcep(Map*, Rgetter);
	- static	int	armfoll(Map*, ulong, Rgetter, ulong*);
	- static	int	arminst(Map*, ulong, char, char*, int);
	- static	int	armdas(Map*, ulong, char*, int);
	- static	int	arminstlen(Map*, ulong);
	+ static	int	armfoll(Map*, uvlong, Rgetter, uvlong*);
	+ static	int	arminst(Map*, uvlong, char, char*, int);
	+ static	int	armdas(Map*, uvlong, char*, int);
	+ static	int	arminstlen(Map*, uvlong);
	  
	  /*
	   *	Debugger interface
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:82,91 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:82,91
	  static char*
	  armexcep(Map *map, Rgetter rget)
	  {
	- 	long c;
	+ 	uvlong c;
	  
	  	c = (*rget)(map, "TYPE");
	- 	switch (c&0x1f) {
	+ 	switch ((int)c&0x1f) {
	  	case 0x11:
	  		return "Fiq interrupt";
	  	case 0x12:
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:196,204 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:196,204
	  }
	  
	  static int
	- decode(Map *map, ulong pc, Instr *i)
	+ decode(Map *map, uvlong pc, Instr *i)
	  {
	- 	long w;
	+ 	ulong w;
	  
	  	if(get4(map, pc, &w) < 0) {
	  		werrstr("can't read instruction: %r");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:232,238 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:232,238
	  	int offset;
	  
	  	if(!findsym(i->addr, CTEXT, &s)) {
	- 		if(debug)fprint(2,"fn not found @%lux: %r\n", i->addr);
	+ 		if(debug)fprint(2,"fn not found @%llux: %r\n", i->addr);
	  		return 0;
	  	}
	  	fn = s.name;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:460,466 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:460,466
	  static int
	  armcondpass(Map *map, Rgetter rget, uchar cond)
	  {
	- 	ulong psr;
	+ 	uvlong psr;
	  	uchar n;
	  	uchar z;
	  	uchar c;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:591,597 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:591,597
	  	}
	  }
	  
	- static ulong
	+ static uvlong
	  armaddr(Map *map, Rgetter rget, Instr *i)
	  {
	  	char buf[8];
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:637,644 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:637,644
	  	}
	  }
	  
	- static ulong
	- armfadd(Map *map, Rgetter rget, Instr *i, ulong pc)
	+ static uvlong
	+ armfadd(Map *map, Rgetter rget, Instr *i, uvlong pc)
	  {
	  	char buf[8];
	  	int r;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:653,660 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:653,660
	  	return rget(map, buf) + armshiftval(map, rget, i);
	  }
	  
	- static ulong
	- armfmovm(Map *map, Rgetter rget, Instr *i, ulong pc)
	+ static uvlong
	+ armfmovm(Map *map, Rgetter rget, Instr *i, uvlong pc)
	  {
	  	ulong v;
	  	ulong addr;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:664,670 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:664,670
	  		return pc+4;
	  
	  	addr = armmaddr(map, rget, i) + nbits(i->w & BITS(0,15));
	- 	if(get4(map, addr, (long*)&v) < 0) {
	+ 	if(get4(map, addr, &v) < 0) {
	  		werrstr("can't read addr: %r");
	  		return -1;
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:671,678 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:671,678
	  	return v;
	  }
	  
	- static ulong
	- armfbranch(Map *map, Rgetter rget, Instr *i, ulong pc)
	+ static uvlong
	+ armfbranch(Map *map, Rgetter rget, Instr *i, uvlong pc)
	  {
	  	if(!armcondpass(map, rget, (i->w >> 28) & 0xf))
	  		return pc+4;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:680,690 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:680,689
	  	return pc + (((signed long)i->w << 8) >> 6) + 8;
	  }
	  
	- static ulong
	- armfmov(Map *map, Rgetter rget, Instr *i, ulong pc)
	+ static uvlong
	+ armfmov(Map *map, Rgetter rget, Instr *i, uvlong pc)
	  {
	- 	ulong rd;
	- 	ulong v;
	+ 	ulong rd, v;
	  
	  	rd = (i->w >> 12) & 0xf;
	  	if(rd != 15 || !armcondpass(map, rget, (i->w>>28)&0xf))
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:693,699 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:692,698
	  	 /* LDR */
	  	/* BUG: Needs LDH/B, too */
	  	if((i->w>>26)&0x3 == 1) {
	- 		if(get4(map, armaddr(map, rget, i), (long*)&v) < 0) {
	+ 		if(get4(map, armaddr(map, rget, i), &v) < 0) {
	  			werrstr("can't read instruction: %r");
	  			return pc+4;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:910,916 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:909,915
	  			fmt = "#%lx(R%d)";
	  			if (i->rn == 15) {
	  				/* convert load of offset(PC) to a load immediate */
	- 				if (get4(i->map, i->addr+i->imm+8, &i->imm) > 0)
	+ 				if (get4(i->map, i->addr+i->imm+8, (ulong*)&i->imm) > 0)
	  				{
	  					g = 1;
	  					fmt = "";
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:921,927 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:920,926
	  				if (i->rd == 11) {
	  					ulong nxti;
	  
	- 					if (get4(i->map, i->addr+4, (long*)&nxti) > 0) {
	+ 					if (get4(i->map, i->addr+4, &nxti) > 0) {
	  						if ((nxti & 0x0e0f0fff) == 0x060c000b) {
	  							i->imm += mach->sb;
	  							g = 1;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:1007,1013 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:1006,1012
	  }
	  
	  static int
	- printins(Map *map, ulong pc, char *buf, int n)
	+ printins(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:1021,1027 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:1020,1026
	  }
	  
	  static int
	- arminst(Map *map, ulong pc, char modifier, char *buf, int n)
	+ arminst(Map *map, uvlong pc, char modifier, char *buf, int n)
	  {
	  	USED(modifier);
	  	return printins(map, pc, buf, n);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:1028,1034 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:1027,1033
	  }
	  
	  static int
	- armdas(Map *map, ulong pc, char *buf, int n)
	+ armdas(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:1043,1049 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:1042,1048
	  }
	  
	  static int
	- arminstlen(Map *map, ulong pc)
	+ arminstlen(Map *map, uvlong pc)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/5db.c:1053,1061 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/5db.c:1052,1060
	  }
	  
	  static int
	- armfoll(Map *map, ulong pc, Rgetter rget, ulong *foll)
	+ armfoll(Map *map, uvlong pc, Rgetter rget, uvlong *foll)
	  {
	- 	ulong d;
	+ 	uvlong d;
	  	Instr i;
	  
	  	if(decode(map, pc, &i) < 0)
 [rsc] --rw-rw-r-- M 451989 jmk sys 3464 Nov  6 10:03 sys/src/libmach/6.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/6.c:2,17 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/6.c:2,14
	   * amd64 definition
	   */
	  #include <u.h>
	+ #include <libc.h>
	  #include <bio.h>
	  #include "/amd64/include/ureg.h"
	  #include <mach.h>
	  
	- #define	REGOFF(x)	(uvlong)(&((struct Ureg *) 0)->x)
	+ #define	REGOFF(x)	offsetof(struct Ureg, x)
	  
	- #define PC		REGOFF(ip)
	- #define SP		REGOFF(sp)
	- #define	AX		REGOFF(ax)
	- 
	  #define	REGSIZE		sizeof(struct Ureg)
	  #define FP_CTLS(x)	(REGSIZE+2*(x))
	  #define FP_CTL(x)	(REGSIZE+4*(x))
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/6.c:26,32 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/6.c:23,29
	  	{"CX",		REGOFF(cx),	RINT, 'Y'},
	  	{"DX",		REGOFF(dx),	RINT, 'Y'},
	  	{"SI",		REGOFF(si),	RINT, 'Y'},
	- 	{"DI",		REGOFF(di),	RINT, 'X'},
	+ 	{"DI",		REGOFF(di),	RINT, 'Y'},
	  	{"BP",		REGOFF(bp),	RINT, 'Y'},
	  	{"R8",		REGOFF(r8),	RINT, 'Y'},
	  	{"R9",		REGOFF(r9),	RINT, 'Y'},
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/6.c:41,61 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/6.c:38,60
	  	{"FS",		REGOFF(fs),	RINT, 'x'},
	  	{"GS",		REGOFF(gs),	RINT, 'x'},
	  	{"TYPE",	REGOFF(type), 	RINT, 'Y'},
	+ 	{"TRAP",	REGOFF(type), 	RINT, 'Y'},	/* alias for acid */
	  	{"ERROR",	REGOFF(error),	RINT, 'Y'},
	- 	{"PC",		PC,		RINT, 'Y'},
	+ 	{"IP",		REGOFF(ip),	RINT, 'Y'},
	+ 	{"PC",		REGOFF(ip),	RINT, 'Y'},	/* alias for acid */
	  	{"CS",		REGOFF(cs),	RINT, 'Y'},
	  	{"FLAGS",	REGOFF(flags),	RINT, 'Y'},
	- 	{"SP",		SP,		RINT, 'Y'},
	+ 	{"SP",		REGOFF(sp),	RINT, 'Y'},
	  	{"SS",		REGOFF(ss),	RINT, 'Y'},
	  
	  	{"FCW",		FP_CTLS(0),	RFLT, 'x'},
	  	{"FSW",		FP_CTLS(1),	RFLT, 'x'},
	- 	{"FTW",		FP_CTLS(2),	RFLT, 'x'},
	+ 	{"FTW",		FP_CTLS(2),	RFLT, 'b'},
	  	{"FOP",		FP_CTLS(3),	RFLT, 'x'},
	- 	{"FPC",		FP_CTL(2),	RFLT, 'Y'},
	+ 	{"RIP",		FP_CTL(2),	RFLT, 'Y'},
	  	{"RDP",		FP_CTL(4),	RFLT, 'Y'},
	  	{"MXCSR",	FP_CTL(6),	RFLT, 'X'},
	- 	{"MXCSRMSK",	FP_CTL(7),	RFLT, 'X'},
	+ 	{"MXCSRMASK",	FP_CTL(7),	RFLT, 'X'},
	  	{"M0",		FP_REG(0),	RFLT, 'F'},	/* assumes double */
	  	{"M1",		FP_REG(1),	RFLT, 'F'},
	  	{"M2",		FP_REG(2),	RFLT, 'F'},
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/6.c:97,117 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/6.c:96,117
	  Mach mamd64=
	  {
	  	"amd64",
	- 	MI386,		/* machine type */	/* TO DO */
	- 	amd64reglist,	/* register list */
	- 	REGSIZE,	/* size of registers in bytes */
	- 	FPREGSIZE,	/* size of fp registers in bytes */
	- 	"PC",		/* name of PC */
	- 	"SP",		/* name of SP */
	- 	0,		/* link register */
	- 	"setSB",	/* static base register name (bogus anyways) */
	- 	0,		/* static base register value */
	- 	0x1000,		/* page size */
	- 	0x80110000,	/* kernel base */	/* TO DO: uvlong or vlong */
	- 	0,		/* kernel text mask */
	- 	1,		/* quantization of pc */
	- 	8,		/* szaddr */
	- 	4,		/* szreg */
	- 	4,		/* szfloat */
	- 	8,		/* szdouble */
	+ 	MAMD64,			/* machine type */
	+ 	amd64reglist,		/* register list */
	+ 	REGSIZE,		/* size of registers in bytes */
	+ 	FPREGSIZE,		/* size of fp registers in bytes */
	+ 	"PC",			/* name of PC */
	+ 	"SP",			/* name of SP */
	+ 	0,			/* link register */
	+ 	"setSB",		/* static base register name (bogus anyways) */
	+ 	0,			/* static base register value */
	+ 	0x1000,			/* page size */
	+ 	0xFFFFFFFF80110000ULL,	/* kernel base */
	+ 	0,			/* kernel text mask */
	+ 	0x00007FFFFFFFF000ULL,	/* user stack top */
	+ 	1,			/* quantization of pc */
	+ 	8,			/* szaddr */
	+ 	4,			/* szreg */
	+ 	4,			/* szfloat */
	+ 	8,			/* szdouble */
	  };
 [rsc] --rw-rw-r-- M 451989 glenda sys 3299 Nov  6 10:03 sys/src/libmach/7.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7.c:103,110 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7.c:103,111
	  	"setSB",	/* static base register name */
	  	0,		/* static base register value */
	  	0x2000,		/* page size */
	- 	0x80000000,	/* kernel base */
	- 	0x00000000,	/* kernel text mask */
	+ 	0x80000000ULL,	/* kernel base */
	+ 	0,		/* kernel text mask */
	+ 	0x7FFFFFFFULL,	/* user stack top */
	  	4,		/* quantization of pc */
	  	4,		/* szaddr */
	  	8,		/* szreg (not used?) */
 [rsc] --rw-rw-r-- M 451989 glenda sys 17330 Nov  6 10:03 sys/src/libmach/7db.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:7,16 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:7,16
	   */
	  
	  static 	char	*alphaexcep(Map*, Rgetter);
	- static	int	alphafoll(Map*, ulong, Rgetter, ulong*);
	- static	int	alphainst(Map*, ulong, char, char*, int);
	- static	int	alphadas(Map*, ulong, char*, int);
	- static	int	alphainstlen(Map*, ulong);
	+ static	int	alphafoll(Map*, uvlong, Rgetter, uvlong*);
	+ static	int	alphainst(Map*, uvlong, char, char*, int);
	+ static	int	alphadas(Map*, uvlong, char*, int);
	+ static	int	alphainstlen(Map*, uvlong);
	  /*
	   *	Debugger interface
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:86,92 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:86,92
	  static	char FRAMENAME[] = ".frame";
	  
	  typedef struct {
	- 	ulong addr;
	+ 	uvlong addr;
	  	uchar op;			/* bits 31-26 */
	  	uchar ra;			/* bits 25-21 */
	  	uchar rb;			/* bits 20-16 */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:109,117 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:109,117
	  static Map *mymap;
	  
	  static int
	- decode(ulong pc, Instr *i)
	+ decode(uvlong pc, Instr *i)
	  {
	- 	long w;
	+ 	ulong w;
	  
	  	if (get4(mymap, pc, &w) < 0) {
	  		werrstr("can't read instruction: %r");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:140,146 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:140,146
	  }
	  
	  static int
	- mkinstr(ulong pc, Instr *i)
	+ mkinstr(uvlong pc, Instr *i)
	  {
	  /*	Instr x; */
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:397,406 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:397,406
	  	"OPC07",	0,	alphaxxx,
	  	"MOVQA",	load,	alphaload,
	  	"MOVQAH",	load,	alphaload,
	- 	"MOVBU",	load,	alphaload,			/* v 3 */
	+ 	"MOVBU",	load,	alphaload,		/* v 3 */
	  	"MOVQU",	load,	alphaload,
	  	"MOVWU",	load,	alphaload,		/* v 3 */
	- 	"MOVWU",	store,	alphastore,	/* v 3 */
	+ 	"MOVWU",	store,	alphastore,		/* v 3 */
	  	"MOVBU",	store,	alphastore,		/* v 3 */
	  	"MOVQU",	store,	alphastore,
	  	0,		0,	0,			/* int arith */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:412,424 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:412,424
	  	0,		0,	0,			/* ieee */
	  	0,		0,	0,			/* fp */
	  	0,		misc,	alphaxxx,
	- 	"PAL19 [HW_MFPR]",	0,	alphaxxx,
	+ 	"PAL19 [HW_MFPR]",0,	alphaxxx,
	  	"JSR",		jmp,	0,
	- 	"PAL1B [HW_LD]",	0,	alphaxxx,
	+ 	"PAL1B [HW_LD]",0,	alphaxxx,
	  	"OPC1C",	0,	alphaxxx,
	- 	"PAL1D [HW_MTPR]",	0,	alphaxxx,
	- 	"PAL1E [HW_REI]",	0,	alphaxxx,
	- 	"PAL1F [HW_ST]",	0,	alphaxxx,
	+ 	"PAL1D [HW_MTPR]",0,	alphaxxx,
	+ 	"PAL1E [HW_REI]",0,	alphaxxx,
	+ 	"PAL1F [HW_ST]",0,	alphaxxx,
	  	"MOVF",		loadf,	alphafload,
	  	"MOVG",		loadf,	alphafload,
	  	"MOVS",		loadf,	alphafload,
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:804,810 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:804,810
	  }
	  
	  static int
	- printins(Map *map, ulong pc, char *buf, int n)
	+ printins(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr i;
	  	Opcode *o;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:855,861 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:855,861
	  }
	  
	  static int
	- alphainst(Map *map, ulong pc, char modifier, char *buf, int n)
	+ alphainst(Map *map, uvlong pc, char modifier, char *buf, int n)
	  {
	  	USED(modifier);
	  	return printins(map, pc, buf, n);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:862,868 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:862,868
	  }
	  
	  static int
	- alphadas(Map *map, ulong pc, char *buf, int n)
	+ alphadas(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:882,888 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:882,888
	  }
	  
	  static int
	- alphainstlen(Map *map, ulong pc)
	+ alphainstlen(Map *map, uvlong pc)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/7db.c:893,899 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/7db.c:893,899
	  }
	  
	  static int
	- alphafoll(Map *map, ulong pc, Rgetter rget, ulong *foll)
	+ alphafoll(Map *map, uvlong pc, Rgetter rget, uvlong *foll)
	  {
	  	char buf[8];
	  	Instr i;
 [rsc] --rw-rw-r-- M 451989 glenda sys 2060 Nov  6 10:03 sys/src/libmach/8.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8.c:68,75 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8.c:68,76
	  	"setSB",	/* static base register name (bogus anyways) */
	  	0,		/* static base register value */
	  	0x1000,		/* page size */
	- 	0x80100000,	/* kernel base */
	+ 	0x80100000ULL,	/* kernel base */
	  	0,		/* kernel text mask */
	+ 	0x7FFFFFFFULL,	/* user stack top */
	  	1,		/* quantization of pc */
	  	4,		/* szaddr */
	  	4,		/* szreg */
 [rsc] --rw-rw-r-- M 451989 glenda sys 50612 Nov  6 10:03 sys/src/libmach/8db.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:10,21 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:10,21
	  
	  static	char	*i386excep(Map*, Rgetter);
	  
	- static	int	i386trace(Map*, ulong, ulong, ulong, Tracer);
	- static	ulong	i386frame(Map*, ulong, ulong, ulong, ulong);
	- static	int	i386foll(Map*, ulong, Rgetter, ulong*);
	- static	int	i386inst(Map*, ulong, char, char*, int);
	- static	int	i386das(Map*, ulong, char*, int);
	- static	int	i386instlen(Map*, ulong);
	+ static	int	i386trace(Map*, uvlong, uvlong, uvlong, Tracer);
	+ static	uvlong	i386frame(Map*, uvlong, uvlong, uvlong, uvlong);
	+ static	int	i386foll(Map*, uvlong, Rgetter, uvlong*);
	+ static	int	i386inst(Map*, uvlong, char, char*, int);
	+ static	int	i386das(Map*, uvlong, char*, int);
	+ static	int	i386instlen(Map*, uvlong);
	  
	  static	char	STARTSYM[] =	"_main";
	  static	char	PROFSYM[] =	"_mainp";
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:74,80 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:74,80
	  i386excep(Map *map, Rgetter rget)
	  {
	  	ulong c;
	- 	ulong pc;
	+ 	uvlong pc;
	  	static char buf[16];
	  
	  	c = (*rget)(map, "TRAP");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:85,91 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:85,91
	  			if (memcmp(buf, machdata->bpinst, machdata->bpsize) == 0)
	  				return "breakpoint";
	  		}
	- 		sprint(buf, "exception %ld", c);
	+ 		snprint(buf, sizeof(buf), "exception %ld", c);
	  		return buf;
	  	} else
	  		return excname[c];
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:92,101 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:92,101
	  }
	  
	  static int
	- i386trace(Map *map, ulong pc, ulong sp, ulong link, Tracer trace)
	+ i386trace(Map *map, uvlong pc, uvlong sp, uvlong link, Tracer trace)
	  {
	  	int i;
	- 	ulong osp;
	+ 	uvlong osp;
	  	Symbol s, f;
	  
	  	USED(link);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:115,121 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:115,121
	  			sp += f.value-mach->szaddr;
	  		}
	  
	- 		if (get4(map, sp, (long *) &pc) < 0)
	+ 		if (geta(map, sp, &pc) < 0)
	  			break;
	  
	  		if(pc == 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:130,137 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:130,137
	  	return i;
	  }
	  
	- static ulong
	- i386frame(Map *map, ulong addr, ulong pc, ulong sp, ulong link)
	+ static uvlong
	+ i386frame(Map *map, uvlong addr, uvlong pc, uvlong sp, uvlong link)
	  {
	  	Symbol s, f;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:149,155 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:149,155
	  		if (s.value == addr)
	  			return sp;
	  
	- 		if (get4(map, sp, (long *)&pc) < 0)
	+ 		if (geta(map, sp, &pc) < 0)
	  			break;
	  		sp += mach->szaddr;
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:165,177 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:165,177
	  struct	Instr
	  {
	  	uchar	mem[1+1+1+1+2+1+1+4+4];		/* raw instruction */
	- 	ulong	addr;		/* address of start of instruction */
	+ 	uvlong	addr;		/* address of start of instruction */
	  	int	n;		/* number of bytes in instruction */
	  	char	*prefix;	/* instr prefix */
	  	char	*segment;	/* segment override */
	  	uchar	jumptype;	/* set to the operand type for jump/ret/call */
	  	uchar	amd64;
	- 	uchar	rex;	/* REX prefix (or zero) */
	+ 	uchar	rex;		/* REX prefix (or zero) */
	  	char	osize;		/* 'W' or 'L' (or 'Q' on amd64) */
	  	char	asize;		/* address size 'W' or 'L' (or 'Q' or amd64) */
	  	uchar	mod;		/* bits 6-7 of mod r/m field */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:179,191 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:179,191
	  	char	ss;		/* bits 6-7 of SIB */
	  	char	index;		/* bits 3-5 of SIB */
	  	char	base;		/* bits 0-2 of SIB */
	- 	char	rip;	/* RIP-relative in amd64 mode */
	- 	uchar	opre;	/* f2/f3 could introduce media */
	+ 	char	rip;		/* RIP-relative in amd64 mode */
	+ 	uchar	opre;		/* f2/f3 could introduce media */
	  	short	seg;		/* segment of far address */
	  	ulong	disp;		/* displacement */
	  	ulong 	imm;		/* immediate */
	  	ulong 	imm2;		/* second immediate operand */
	- 	uvlong	imm64;	/* big immediate */
	+ 	uvlong	imm64;		/* big immediate */
	  	char	*curr;		/* fill level in output buffer */
	  	char	*end;		/* end of output buffer */
	  	char	*err;		/* error message */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:215,221 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:215,221
	  
	  	/* amd64 rex extension byte */
	  enum{
	- 	REXW	= 1<<3,	/* =1, 64-bit operand size */
	+ 	REXW		= 1<<3,	/* =1, 64-bit operand size */
	  	REXR		= 1<<2,	/* extend modrm reg */
	  	REXX		= 1<<1,	/* extend sib index */
	  	REXB		= 1<<0	/* extend modrm r/m, sib base, or opcode reg */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:255,261 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:255,261
	  	Iw,			/* 16-bit immediate -> imm */
	  	Iw2,			/* 16-bit immediate -> imm2 */
	  	Iwd,			/* Operand-sized immediate (no sign extension)*/
	- 	Iwdq,		/* Operand-sized immediate, possibly 64 bits */
	+ 	Iwdq,			/* Operand-sized immediate, possibly 64 bits */
	  	Awd,			/* Address offset */
	  	Iwds,			/* Operand-sized immediate (sign extended) */
	  	RM,			/* Word or long R/M field with register (/r) */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:273,281 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:273,281
	  	OA,			/* literal 0x0a byte */
	  	PTR,			/* Seg:Displacement addr (ptr16:16 or ptr16:32) */
	  	AUX,			/* Multi-byte op code - Auxiliary table */
	- 	AUXMM,		/* multi-byte op code - auxiliary table chosen by prefix */
	+ 	AUXMM,			/* multi-byte op code - auxiliary table chosen by prefix */
	  	PRE,			/* Instr Prefix */
	- 	OPRE,		/* Instr Prefix or media op extension */
	+ 	OPRE,			/* Instr Prefix or media op extension */
	  	SEG,			/* Segment Prefix */
	  	OPOVER,			/* Operand size override */
	  	ADDOVER,		/* Address size override */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:299,305 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:299,305
	  [0x03]	0,0,		"MOVL	%e,IDTR",
	  [0x04]	0,0,		"MOVW	MSW,%e",	/* word */
	  [0x06]	0,0,		"MOVW	%e,MSW",	/* word */
	- [0x07]	0,0,		"INVLPG	%e",	/* TO DO: distinguish SWAPGS? */
	+ [0x07]	0,0,		"INVLPG	%e",		/* TO DO: distinguish SWAPGS? */
	  };
	  
	  /* 0F71 */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:330,358 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:330,358
	  
	  static Optable optab0F0F[256]=
	  {
	- [0x0c]	0,0,	"PI2FW	%m,%M",
	- [0x0d]	0,0,	"PI2L	%m,%M",
	- [0x1c]	0,0,	"PF2IW	%m,%M",
	- [0x1d]	0,0,	"PF2IL	%m,%M",
	- [0x8a]	0,0,	"PFNACC	%m,%M",
	- [0x8e]	0,0,	"PFPNACC	%m,%M",
	- [0x90]	0,0,	"PFCMPGE	%m,%M",
	- [0x94]	0,0,	"PFMIN	%m,%M",
	- [0x96]	0,0,	"PFRCP	%m,%M",
	- [0x97]	0,0,	"PFRSQRT	%m,%M",
	- [0x9a]	0,0,	"PFSUB	%m,%M",
	- [0x9e]	0,0,	"PFADD	%m,%M",
	- [0xa0]	0,0,	"PFCMPGT	%m,%M",
	- [0xa4]	0,0,	"PFMAX	%m,%M",
	- [0xa6]	0,0,	"PFRCPIT1	%m,%M",
	- [0xa7]	0,0,	"PFRSQIT1	%m,%M",
	- [0xaa]	0,0,	"PFSUBR	%m,%M",
	- [0xae]	0,0,	"PFACC	%m,%M",
	- [0xb0]	0,0,	"PFCMPEQ	%m,%M",
	- [0xb4]	0,0,	"PFMUL	%m,%M",
	- [0xb6]	0,0,	"PFRCPI2T	%m,%M",
	- [0xb7]	0,0,	"PMULHRW	%m,%M",
	- [0xbb]	0,0,	"PSWAPL	%m,%M",
	+ [0x0c]	0,0,		"PI2FW	%m,%M",
	+ [0x0d]	0,0,		"PI2L	%m,%M",
	+ [0x1c]	0,0,		"PF2IW	%m,%M",
	+ [0x1d]	0,0,		"PF2IL	%m,%M",
	+ [0x8a]	0,0,		"PFNACC	%m,%M",
	+ [0x8e]	0,0,		"PFPNACC	%m,%M",
	+ [0x90]	0,0,		"PFCMPGE	%m,%M",
	+ [0x94]	0,0,		"PFMIN	%m,%M",
	+ [0x96]	0,0,		"PFRCP	%m,%M",
	+ [0x97]	0,0,		"PFRSQRT	%m,%M",
	+ [0x9a]	0,0,		"PFSUB	%m,%M",
	+ [0x9e]	0,0,		"PFADD	%m,%M",
	+ [0xa0]	0,0,		"PFCMPGT	%m,%M",
	+ [0xa4]	0,0,		"PFMAX	%m,%M",
	+ [0xa6]	0,0,		"PFRCPIT1	%m,%M",
	+ [0xa7]	0,0,		"PFRSQIT1	%m,%M",
	+ [0xaa]	0,0,		"PFSUBR	%m,%M",
	+ [0xae]	0,0,		"PFACC	%m,%M",
	+ [0xb0]	0,0,		"PFCMPEQ	%m,%M",
	+ [0xb4]	0,0,		"PFMUL	%m,%M",
	+ [0xb6]	0,0,		"PFRCPI2T	%m,%M",
	+ [0xb7]	0,0,		"PMULHRW	%m,%M",
	+ [0xbb]	0,0,		"PSWAPL	%m,%M",
	  };
	  
	  static Optable optab0FC7[8]=
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:385,392 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:385,392
	  static Optable optab660F[256]=
	  {
	  [0x2B]	RM,0,		"MOVNTPD	%x,%e",
	- [0x2E]	RM,0,	"UCOMISD	%x,%X",
	- [0x2F]	RM,0,	"COMISD	%x,%X",
	+ [0x2E]	RM,0,		"UCOMISD	%x,%X",
	+ [0x2F]	RM,0,		"COMISD	%x,%X",
	  [0x5A]	RM,0,		"CVTPD2PS	%x,%X",
	  [0x5B]	RM,0,		"CVTPS2PL	%x,%X",
	  [0x6A]	RM,0,		"PUNPCKHLQ %x,%X",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:394,400 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:394,400
	  [0x6C]	RM,0,		"PUNPCKLQDQ %x,%X",
	  [0x6D]	RM,0,		"PUNPCKHQDQ %x,%X",
	  [0x6E]	RM,0,		"MOV%S	%e,%X",
	- [0x6F]	RM,0,		"MOVO	%x,%X",	/* MOVDQA */
	+ [0x6F]	RM,0,		"MOVO	%x,%X",		/* MOVDQA */
	  [0x70]	RM,Ib,		"PSHUFL	%i,%x,%X",
	  [0x71]	RMOP,0,		optab660F71,
	  [0x72]	RMOP,0,		optab660F72,
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:413,420 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:413,420
	  
	  static Optable optabF20F[256]=
	  {
	- [0x10]	RM,0,	"MOVSD	%x,%X",
	- [0x11]	RM,0,	"MOVSD	%X,%x",
	+ [0x10]	RM,0,		"MOVSD	%x,%X",
	+ [0x11]	RM,0,		"MOVSD	%X,%x",
	  [0x2A]	RM,0,		"CVTS%S2SD	%e,%X",
	  [0x2C]	RM,0,		"CVTTSD2S%S	%x,%r",
	  [0x2D]	RM,0,		"CVTSD2S%S	%x,%r",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:428,435 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:428,435
	  
	  static Optable optabF30F[256]=
	  {
	- [0x10]	RM,0,	"MOVSS	%x,%X",
	- [0x11]	RM,0,	"MOVSS	%X,%x",
	+ [0x10]	RM,0,		"MOVSS	%x,%X",
	+ [0x11]	RM,0,		"MOVSS	%X,%x",
	  [0x2A]	RM,0,		"CVTS%S2SS	%e,%X",
	  [0x2C]	RM,0,		"CVTTSS2S%S	%x,%r",
	  [0x2D]	RM,0,		"CVTSS2S%S	%x,%r",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:449,467 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:449,469
	  [0x01]	RMOP,0,		optab0F01,
	  [0x02]	RM,0,		"LAR	%e,%r",
	  [0x03]	RM,0,		"LSL	%e,%r",
	+ [0x05]	0,0,		"SYSCALL",
	  [0x06]	0,0,		"CLTS",
	  [0x07]	0,0,		"SYSRET",
	  [0x08]	0,0,		"INVD",
	  [0x09]	0,0,		"WBINVD",
	- [0x0F]	RM,AUX,	optab0F0F,	/* 3DNow! */
	- [0x10]	RM,0,	"MOVU%s	%x,%X",
	- [0x11]	RM,0,	"MOVU%s	%X,%x",
	- [0x12]	RM,0,	"MOV[H]L%s	%x,%X",	/* TO DO: H if source is XMM */
	- [0x13]	RM,0,	"MOVL%s	%X,%e",
	- [0x14]	RM,0,	"UNPCKL%s	%x,%X",
	- [0x15]	RM,0,	"UNPCKH%s	%x,%X",
	- [0x16]	RM,0,	"MOV[L]H%s	%x,%X",	/* TO DO: L if source is XMM */
	- [0x17]	RM,0,	"MOVH%s	%X,%x",
	+ [0x0B]	0,0,		"UD2",
	+ [0x0F]	RM,AUX,		optab0F0F,		/* 3DNow! */
	+ [0x10]	RM,0,		"MOVU%s	%x,%X",
	+ [0x11]	RM,0,		"MOVU%s	%X,%x",
	+ [0x12]	RM,0,		"MOV[H]L%s	%x,%X",	/* TO DO: H if source is XMM */
	+ [0x13]	RM,0,		"MOVL%s	%X,%e",
	+ [0x14]	RM,0,		"UNPCKL%s	%x,%X",
	+ [0x15]	RM,0,		"UNPCKH%s	%x,%X",
	+ [0x16]	RM,0,		"MOV[L]H%s	%x,%X",	/* TO DO: L if source is XMM */
	+ [0x17]	RM,0,		"MOVH%s	%X,%x",
	  [0x20]	RMR,0,		"MOVL	%C,%e",
	  [0x21]	RMR,0,		"MOVL	%D,%e",
	  [0x22]	RMR,0,		"MOVL	%e,%C",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:468,481 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:470,483
	  [0x23]	RMR,0,		"MOVL	%e,%D",
	  [0x24]	RMR,0,		"MOVL	%T,%e",
	  [0x26]	RMR,0,		"MOVL	%e,%T",
	- [0x28]	RM,0,	"MOVA%s	%x,%X",
	- [0x29]	RM,0,	"MOVA%s	%X,%x",
	- [0x2A]	RM,0,	"CVTPL2%s	%m*,%X",
	- [0x2B]	RM,0,	"MOVNT%s	%X,%e",
	- [0x2C]	RM,0,	"CVTT%s2PL	%x,%M",
	- [0x2D]	RM,0,	"CVT%s2PL	%x,%M",
	- [0x2E]	RM,0,	"UCOMISS	%x,%X",
	- [0x2F]	RM,0,	"COMISS	%x,%X",
	+ [0x28]	RM,0,		"MOVA%s	%x,%X",
	+ [0x29]	RM,0,		"MOVA%s	%X,%x",
	+ [0x2A]	RM,0,		"CVTPL2%s	%m*,%X",
	+ [0x2B]	RM,0,		"MOVNT%s	%X,%e",
	+ [0x2C]	RM,0,		"CVTT%s2PL	%x,%M",
	+ [0x2D]	RM,0,		"CVT%s2PL	%x,%M",
	+ [0x2E]	RM,0,		"UCOMISS	%x,%X",
	+ [0x2F]	RM,0,		"COMISS	%x,%X",
	  [0x30]	0,0,		"WRMSR",
	  [0x31]	0,0,		"RDTSC",
	  [0x32]	0,0,		"RDMSR",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:500,514 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:502,516
	  [0x53]	RM,0,		"RCP%s	%x,%X",
	  [0x54]	RM,0,		"AND%s	%x,%X",
	  [0x55]	RM,0,		"ANDN%s	%x,%X",
	- [0x56]	RM,0,		"OR%s	%x,%X",	/* TO DO: S/D */
	- [0x57]	RM,0,		"XOR%s	%x,%X",	/* S/D */
	- [0x58]	RM,0,		"ADD%s	%x,%X",	/* S/P S/D */
	+ [0x56]	RM,0,		"OR%s	%x,%X",		/* TO DO: S/D */
	+ [0x57]	RM,0,		"XOR%s	%x,%X",		/* S/D */
	+ [0x58]	RM,0,		"ADD%s	%x,%X",		/* S/P S/D */
	  [0x59]	RM,0,		"MUL%s	%x,%X",
	  [0x5A]	RM,0,		"CVTPS2PD	%x,%X",
	  [0x5B]	RM,0,		"CVTPL2PS	%x,%X",
	  [0x5C]	RM,0,		"SUB%s	%x,%X",
	  [0x5D]	RM,0,		"MIN%s	%x,%X",
	- [0x5E]	RM,0,		"DIV%s	%x,%X",	/* TO DO: S/P S/D */
	+ [0x5E]	RM,0,		"DIV%s	%x,%X",		/* TO DO: S/P S/D */
	  [0x5F]	RM,0,		"MAX%s	%x,%X",
	  [0x60]	RM,0,		"PUNPCKLBW %m,%M",
	  [0x61]	RM,0,		"PUNPCKLWL %m,%M",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:531,537 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:533,539
	  [0x7E]	RM,0,		"MOV%S %M,%e",
	  [0x7F]	RM,0,		"MOVQ %M,%m",
	  [0xAE]	RMOP,0,		optab0FAE,
	- [0xAA]	0,0,			"RSM",
	+ [0xAA]	0,0,		"RSM",
	  [0xB0]	RM,0,		"CMPXCHGB	%r,%e",
	  [0xB1]	RM,0,		"CMPXCHG%S	%r,%e",
	  [0xC0]	RMB,0,		"XADDB	%r,%e",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:539,544 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:541,554
	  [0xC2]	RM,Ib,		"CMP%s	%i,%x,%X",
	  [0xC3]	RM,0,		"MOVNTI%S	%r,%e",
	  [0xC6]	RM,Ib,		"SHUF%s	%i,%x,%X",
	+ [0xC8]	0,0,		"BSWAP	AX",
	+ [0xC9]	0,0,		"BSWAP	CX",
	+ [0xCA]	0,0,		"BSWAP	DX",
	+ [0xCB]	0,0,		"BSWAP	BX",
	+ [0xCC]	0,0,		"BSWAP	SP",
	+ [0xCD]	0,0,		"BSWAP	BP",
	+ [0xCE]	0,0,		"BSWAP	SI",
	+ [0xCF]	0,0,		"BSWAP	DI",
	  [0xD1]	RM,0,		"PSRLW %m,%M",
	  [0xD2]	RM,0,		"PSRLL %m,%M",
	  [0xD3]	RM,0,		"PSRLQ %m,%M",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:969,975 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:979,985
	  [0x0c]	Ib,0,		"ORB	%i,AL",
	  [0x0d]	Iwd,0,		"OR%S	%i,%OAX",
	  [0x0e]	0,0,		"PUSHL	CS",
	- [0x0f]	AUXMM,0,		optab0F,
	+ [0x0f]	AUXMM,0,	optab0F,
	  [0x10]	RMB,0,		"ADCB	%r,%e",
	  [0x11]	RM,0,		"ADC%S	%r,%e",
	  [0x12]	RMB,0,		"ADCB	%e,%r",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1094,1100 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1104,1110
	  [0x8a]	RMB,0,		"MOVB	%e,%r",
	  [0x8b]	RM,0,		"MOV%S	%e,%r",
	  [0x8c]	RM,0,		"MOVW	%g,%e",
	- [0x8d]	RM,0,		"LEA	%e,%r",
	+ [0x8d]	RM,0,		"LEA%S	%e,%r",
	  [0x8e]	RM,0,		"MOVW	%e,%g",
	  [0x8f]	RM,0,		"POP%S	%e",
	  [0x90]	0,0,		"NOP",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1214,1220 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1224,1230
	   *  get a byte of the instruction
	   */
	  static int
	- igetc(Map * map, Instr *ip, uchar *c)
	+ igetc(Map *map, Instr *ip, uchar *c)
	  {
	  	if(ip->n+1 > sizeof(ip->mem)){
	  		werrstr("instruction too long");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1234,1240 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1244,1250
	  static int
	  igets(Map *map, Instr *ip, ushort *sp)
	  {
	- 	uchar	c;
	+ 	uchar c;
	  	ushort s;
	  
	  	if (igetc(map, ip, &c) < 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1378,1384 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1388,1394
	  }
	  
	  static Optable *
	- mkinstr(Map *map, Instr *ip, ulong pc)
	+ mkinstr(Map *map, Instr *ip, uvlong pc)
	  {
	  	int i, n, norex;
	  	uchar c;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1451,1456 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1461,1467
	  					ip->imm = c|0xff00;
	  			else
	  				ip->imm = c&0xff;
	+ 			ip->imm64 = (long)ip->imm;
	  			break;
	  		case Iw:	/* 16-bit immediate -> imm */
	  			if (igets(map, ip, &s) < 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1819,1825 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1830,1836
	  	Symbol s;
	  	long w;
	  
	- 	if (findsym((long)val, CANY, &s)) {	/* TO DO */
	+ 	if (findsym(val, CANY, &s)) {		/* TO DO */
	  		w = val - s.value;
	  		if (w < 0)
	  			w = -w;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:1981,1987 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:1992,2002
	  				bprint(ip,"???");
	  			break;
	  		case 'p':
	- 			immediate(ip, ip->imm+ip->addr+ip->n);
	+ 			/*
	+ 			 * signed immediate in the ulong ip->imm.
	+ 			 */
	+ 			v = (long)ip->imm;
	+ 			immediate(ip, v+ip->addr+ip->n);
	  			break;
	  		case 'r':
	  			if (ip->osize == 'B')
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2022,2030 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2037,2045
	  }
	  
	  static int
	- i386inst(Map *map, ulong pc, char modifier, char *buf, int n)
	+ i386inst(Map *map, uvlong pc, char modifier, char *buf, int n)
	  {
	- 	Instr	instr;
	+ 	Instr instr;
	  	Optable *op;
	  
	  	USED(modifier);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2040,2048 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2055,2063
	  }
	  
	  static int
	- i386das(Map *map, ulong pc, char *buf, int n)
	+ i386das(Map *map, uvlong pc, char *buf, int n)
	  {
	- 	Instr	instr;
	+ 	Instr instr;
	  	int i;
	  
	  	if (mkinstr(map, &instr, pc) == 0) {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2059,2065 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2074,2080
	  }
	  
	  static int
	- i386instlen(Map *map, ulong pc)
	+ i386instlen(Map *map, uvlong pc)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2069,2080 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2084,2096
	  }
	  
	  static int
	- i386foll(Map *map, ulong pc, Rgetter rget, ulong *foll)
	+ i386foll(Map *map, uvlong pc, Rgetter rget, uvlong *foll)
	  {
	  	Instr i;
	  	Optable *op;
	  	ushort s;
	- 	ulong l, addr;
	+ 	uvlong l, addr;
	+ 	vlong v;
	  	int n;
	  
	  	op = mkinstr(map, &i, pc);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2087,2101 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2103,2118
	  	case RET:		/* RETURN or LEAVE */
	  	case Iw:		/* RETURN */
	  		if (strcmp(op->proto, "LEAVE") == 0) {
	- 			if (get4(map, (*rget)(map, "BP"), (long*)&l) < 0)
	+ 			if (geta(map, (*rget)(map, "BP"), &l) < 0)
	  				return -1;
	- 		} else if (get4(map, (*rget)(map, mach->sp), (long*)&l) < 0)
	+ 		} else if (geta(map, (*rget)(map, mach->sp), &l) < 0)
	  			return -1;
	  		foll[0] = l;
	  		return 1;
	  	case Iwds:		/* pc relative JUMP or CALL*/
	  	case Jbs:		/* pc relative JUMP or CALL */
	- 		foll[0] = pc+i.imm+i.n;
	+ 		v = (long)i.imm;
	+ 		foll[0] = pc+v+i.n;
	  		n = 1;
	  		break;
	  	case PTR:		/* seg:displacement JUMP or CALL */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/8db.c:2110,2131 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/8db.c:2127,2148
	  			/* calculate the effective address */
	  		addr = i.disp;
	  		if (i.base >= 0) {
	- 			if (get4(map, (*rget)(map, reg[i.rex&REXB? i.base+8: i.base]), (long*)&l) < 0)
	+ 			if (geta(map, (*rget)(map, reg[i.rex&REXB? i.base+8: i.base]), &l) < 0)
	  				return -1;
	  			addr += l;
	  		}
	  		if (i.index >= 0) {
	- 			if (get4(map, (*rget)(map, reg[i.rex&REXX? i.index+8: i.index]), (long*)&l) < 0)
	+ 			if (geta(map, (*rget)(map, reg[i.rex&REXX? i.index+8: i.index]), &l) < 0)
	  				return -1;
	  			addr += l*(1<<i.ss);
	  		}
	  			/* now retrieve a seg:disp value at that address */
	- 		if (get2(map, addr, &s) < 0)		/* seg */
	+ 		if (get2(map, addr, &s) < 0)			/* seg */
	  			return -1;
	  		foll[0] = s<<4;
	  		addr += 2;
	  		if (i.asize == 'L') {
	- 			if (get4(map, addr, (long*)&l) < 0)	/* disp32 */
	+ 			if (geta(map, addr, &l) < 0)		/* disp32 */
	  				return -1;
	  			foll[0] += l;
	  		} else {					/* disp16 */
 [rsc] --rw-rw-r-- M 451989 glenda sys 4588 Nov  6 10:02 sys/src/libmach/access.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:7,22 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:7,41
	  #include <bio.h>
	  #include <mach.h>
	  
	- static	int	mget(Map*, ulong, char*, int);
	- static	int	mput(Map*, ulong, char*, int);
	- static	struct	segment*	reloc(Map*, ulong, long*);
	+ static	int	mget(Map*, uvlong, void*, int);
	+ static	int	mput(Map*, uvlong, void*, int);
	+ static	struct	segment*	reloc(Map*, uvlong, vlong*);
	  
	  /*
	   * routines to get/put various types
	   */
	+ int
	+ geta(Map *map, uvlong addr, uvlong *x)
	+ {
	+ 	ulong l;
	+ 	uvlong vl;
	  
	+ 	if (mach->szaddr == 8){
	+ 		if (get8(map, addr, &vl) < 0)
	+ 			return -1;
	+ 		*x = vl;
	+ 		return 1;
	+ 	}
	+ 
	+ 	if (get4(map, addr, &l) < 0)
	+ 		return -1;
	+ 	*x = l;
	+ 
	+ 	return 1;
	+ }
	+ 
	  int
	- get8(Map *map, ulong addr, vlong *x)
	+ get8(Map *map, uvlong addr, uvlong *x)
	  {
	  	if (!map) {
	  		werrstr("get8: invalid map");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:24,40 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:43,59
	  	}
	  
	  	if (map->nsegs == 1 && map->seg[0].fd < 0) {
	- 		*x = (vlong)addr;
	+ 		*x = addr;
	  		return 1;
	  	}
	- 	if (mget(map, addr, (char *)x, 8) < 0)
	+ 	if (mget(map, addr, x, 8) < 0)
	  		return -1;
	  	*x = machdata->swav(*x);
	- 	return (1);
	+ 	return 1;
	  }
	  
	  int
	- get4(Map *map, ulong addr, long *x)
	+ get4(Map *map, uvlong addr, ulong *x)
	  {
	  	if (!map) {
	  		werrstr("get4: invalid map");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:45,58 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:64,77
	  		*x = addr;
	  		return 1;
	  	}
	- 	if (mget(map, addr, (char *)x, 4) < 0)
	+ 	if (mget(map, addr, x, 4) < 0)
	  		return -1;
	  	*x = machdata->swal(*x);
	- 	return (1);
	+ 	return 1;
	  }
	  
	  int
	- get2(Map *map, ulong addr, ushort *x)
	+ get2(Map *map, uvlong addr, ushort *x)
	  {
	  	if (!map) {
	  		werrstr("get2: invalid map");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:63,76 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:82,95
	  		*x = addr;
	  		return 1;
	  	}
	- 	if (mget(map, addr, (char *)x, 2) < 0)
	+ 	if (mget(map, addr, x, 2) < 0)
	  		return -1;
	  	*x = machdata->swab(*x);
	- 	return (1);
	+ 	return 1;
	  }
	  
	  int
	- get1(Map *map, ulong addr, uchar *x, int size)
	+ get1(Map *map, uvlong addr, uchar *x, int size)
	  {
	  	uchar *cp;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:86,108 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:105,136
	  		while (size-- > 0)
	  			*x++ = 0;
	  	} else
	- 		return mget(map, addr, (char*)x, size);
	+ 		return mget(map, addr, x, size);
	  	return 1;
	  }
	  
	  int
	- put8(Map *map, ulong addr, vlong v)
	+ puta(Map *map, uvlong addr, uvlong v)
	  {
	+ 	if (mach->szaddr == 8)
	+ 		return put8(map, addr, v);
	+ 
	+ 	return put4(map, addr, v);
	+ }
	+ 
	+ int
	+ put8(Map *map, uvlong addr, uvlong v)
	+ {
	  	if (!map) {
	  		werrstr("put8: invalid map");
	  		return -1;
	  	}
	  	v = machdata->swav(v);
	- 	return mput(map, addr, (char *)&v, 8);
	+ 	return mput(map, addr, &v, 8);
	  }
	  
	  int
	- put4(Map *map, ulong addr, long v)
	+ put4(Map *map, uvlong addr, ulong v)
	  {
	  	if (!map) {
	  		werrstr("put4: invalid map");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:109,119 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:137,147
	  		return -1;
	  	}
	  	v = machdata->swal(v);
	- 	return mput(map, addr, (char *)&v, 4);
	+ 	return mput(map, addr, &v, 4);
	  }
	  
	  int
	- put2(Map *map, ulong addr, ushort v)
	+ put2(Map *map, uvlong addr, ushort v)
	  {
	  	if (!map) {
	  		werrstr("put2: invalid map");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:120,147 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:148,175
	  		return -1;
	  	}
	  	v = machdata->swab(v);
	- 	return mput(map, addr, (char *)&v, 2);
	+ 	return mput(map, addr, &v, 2);
	  }
	  
	  int
	- put1(Map *map, ulong addr, uchar *v, int size)
	+ put1(Map *map, uvlong addr, uchar *v, int size)
	  {
	  	if (!map) {
	  		werrstr("put1: invalid map");
	  		return -1;
	  	}
	- 	return mput(map, addr, (char *)v, size);
	+ 	return mput(map, addr, v, size);
	  }
	  
	  static int
	- spread(struct segment *s, char *buf, int n, ulong off)
	+ spread(struct segment *s, void *buf, int n, uvlong off)
	  {
	- 	ulong base;
	+ 	uvlong base;
	  
	  	static struct {
	  		struct segment *s;
	  		char a[8192];
	- 		ulong off;
	+ 		uvlong off;
	  	} cache;
	  
	  	if(s->cache){
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:167,180 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:195,207
	  }
	  
	  static int
	- mget(Map *map, ulong addr, char *buf, int size)
	+ mget(Map *map, uvlong addr, void *buf, int size)
	  {
	- 	long off;
	- 	uvlong voff;
	+ 	uvlong off;
	  	int i, j, k;
	  	struct segment *s;
	  
	- 	s = reloc(map, addr, &off);
	+ 	s = reloc(map, addr, (vlong*)&off);
	  	if (!s)
	  		return -1;
	  	if (s->fd < 0) {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:181,191 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:208,217
	  		werrstr("unreadable map");
	  		return -1;
	  	}
	- 	voff = (ulong)off;
	  	for (i = j = 0; i < 2; i++) {	/* in case read crosses page */
	- 		k = spread(s, buf, size-j, voff+j);
	+ 		k = spread(s, buf, size-j, off+j);
	  		if (k < 0) {
	- 			werrstr("can't read address %lux: %r", addr);
	+ 			werrstr("can't read address %llux: %r", addr);
	  			return -1;
	  		}
	  		j += k;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:192,206 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:218,231
	  		if (j == size)
	  			return j;
	  	}
	- 	werrstr("partial read at address %lux", addr);
	+ 	werrstr("partial read at address %llux (size %d j %d)", addr, size, j);
	  	return -1;
	  }
	  
	  static int
	- mput(Map *map, ulong addr, char *buf, int size)
	+ mput(Map *map, uvlong addr, void *buf, int size)
	  {
	- 	long off;
	- 	vlong voff;
	+ 	vlong off;
	  	int i, j, k;
	  	struct segment *s;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:212,223 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:237,247
	  		return -1;
	  	}
	  
	- 	voff = (ulong)off;
	- 	seek(s->fd, voff, 0);
	+ 	seek(s->fd, off, 0);
	  	for (i = j = 0; i < 2; i++) {	/* in case read crosses page */
	  		k = write(s->fd, buf, size-j);
	  		if (k < 0) {
	- 			werrstr("can't write address %lux: %r", addr);
	+ 			werrstr("can't write address %llux: %r", addr);
	  			return -1;
	  		}
	  		j += k;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:224,230 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:248,254
	  		if (j == size)
	  			return j;
	  	}
	- 	werrstr("partial write at address %lux", addr);
	+ 	werrstr("partial write at address %llux", addr);
	  	return -1;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:232,238 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:256,262
	   *	convert address to file offset; returns nonzero if ok
	   */
	  static struct segment*
	- reloc(Map *map, ulong addr, long *offp)
	+ reloc(Map *map, uvlong addr, vlong *offp)
	  {
	  	int i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/access.c:243,248 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/access.c:267,272
	  			return &map->seg[i];
	  		}
	  	}
	- 	werrstr("can't translate address %lux", addr);
	+ 	werrstr("can't translate address %llux", addr);
	  	return 0;
	  }
 [rsc] --rw-rw-r-- M 451989 glenda sys 16128 Nov  6 10:02 sys/src/libmach/executable.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:12,25 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:12,28
	  
	  typedef struct {
	  	union{
	- 		Exec;			/* in a.out.h */
	- 		Ehdr;			/* in elf.h */
	- 		struct mipsexec;
	- 		struct mips4kexec;
	- 		struct sparcexec;
	- 		struct nextexec;
	+ 		struct {
	+ 			Exec;		/* a.out.h */
	+ 			uvlong hdr[1];
	+ 		};
	+ 		Ehdr;			/* elf.h */
	+ 		struct mipsexec;	/* bootexec.h */
	+ 		struct mips4kexec;	/* bootexec.h */
	+ 		struct sparcexec;	/* bootexec.h */
	+ 		struct nextexec;	/* bootexec.h */
	  	} e;
	- 	long dummy;		/* padding to ensure extra long */
	+ 	long dummy;			/* padding to ensure extra long */
	  } ExecHdr;
	  
	  static	int	nextboot(int, Fhdr*, ExecHdr*);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:27,42 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:30,45
	  static	int	mipsboot(int, Fhdr*, ExecHdr*);
	  static	int	mips4kboot(int, Fhdr*, ExecHdr*);
	  static	int	common(int, Fhdr*, ExecHdr*);
	+ static	int	commonllp64(int, Fhdr*, ExecHdr*);
	  static	int	adotout(int, Fhdr*, ExecHdr*);
	  static	int	elfdotout(int, Fhdr*, ExecHdr*);
	  static	int	armdotout(int, Fhdr*, ExecHdr*);
	  static	int	alphadotout(int, Fhdr*, ExecHdr*);
	- static	void	setsym(Fhdr*, long, long, long, long);
	- static	void	setdata(Fhdr*, long, long, long, long);
	- static	void	settext(Fhdr*, long, long, long, long);
	- static	void	hswal(long*, int, long(*)(long));
	- static	long	noswal(long);
	- static	ulong	_round(ulong, ulong);
	+ static	void	setsym(Fhdr*, long, long, long, vlong);
	+ static	void	setdata(Fhdr*, uvlong, long, vlong, long);
	+ static	void	settext(Fhdr*, uvlong, uvlong, long, vlong);
	+ static	void	hswal(void*, int, ulong(*)(ulong));
	+ static	uvlong	_round(uvlong, ulong);
	  
	  /*
	   *	definition of per-executable file type structures
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:48,55 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:51,58
	  	char	*dlmname;		/* dynamically loadable module identifier */
	  	int	type;			/* Internal code */
	  	Mach	*mach;			/* Per-machine data */
	- 	ulong	hsize;			/* header size */
	- 	long	(*swal)(long);		/* beswal or leswal */
	+ 	long	hsize;			/* header size */
	+ 	ulong	(*swal)(ulong);		/* beswal or leswal */
	  	int	(*hparse)(int, Fhdr*, ExecHdr*);
	  } ExecTable;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:160,168 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:163,171
	  		"amd64 plan 9 dlm",
	  		FAMD64,
	  		&mamd64,
	- 		sizeof(Exec),
	- 		beswal,
	- 		common },
	+ 		sizeof(Exec)+8,
	+ 		nil,
	+ 		commonllp64 },
	  	{ Q_MAGIC,			/* PowerPC q.out & boot image */
	  		"power plan 9 executable",
	  		"power plan 9 dlm",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:177,183 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:180,186
	  		FNONE,
	  		&mi386,
	  		sizeof(Ehdr),
	- 		noswal,
	+ 		nil,
	  		elfdotout },
	  	{ E_MAGIC,			/* Arm 5.out */
	  		"arm plan 9 executable",
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:242,248 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:245,252
	  {
	  	ExecTable *mp;
	  	ExecHdr d;
	- 	int nb, magic, ret;
	+ 	int nb, ret;
	+ 	ulong magic;
	  
	  	fp->type = FNONE;
	  	nb = read(fd, (char *)&d.e, sizeof(d.e));
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:258,264 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:262,267
	  			if(mp->magic == V_MAGIC)
	  				mp = couldbe4k(mp);
	  
	- 			hswal((long *) &d, sizeof(d.e)/sizeof(long), mp->swal);
	  			fp->type = mp->type;
	  			if ((magic & DYN_MAGIC) && mp->dlmname != nil)
	  				fp->name = mp->dlmname;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:266,272 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:269,277
	  				fp->name = mp->name;
	  			fp->hdrsz = mp->hsize;		/* zero on bootables */
	  			mach = mp->mach;
	- 			ret  = mp->hparse(fd, fp, &d);
	+ 			if(mp->swal != nil)
	+ 				hswal(&d, sizeof(d.e)/sizeof(ulong), mp->swal);
	+ 			ret = mp->hparse(fd, fp, &d);
	  			seek(fd, mp->hsize, 0);		/* seek to end of header */
	  			break;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:275,300 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:280,299
	  		werrstr("unknown header type");
	  	return ret;
	  }
	+ 
	  /*
	   * Convert header to canonical form
	   */
	  static void
	- hswal(long *lp, int n, long (*swap) (long))
	+ hswal(void *v, int n, ulong (*swap)(ulong))
	  {
	- 	while (n--) {
	- 		*lp = (*swap) (*lp);
	- 		lp++;
	- 	}
	+ 	ulong *ulp;
	+ 
	+ 	for(ulp = v; n--; ulp++)
	+ 		*ulp = (*swap)(*ulp);
	  }
	+ 
	  /*
	-  * noop
	-  */
	- static long
	- noswal(long x)
	- {
	- 	return x;
	- }
	- /*
	   *	Crack a normal a.out-type header
	   */
	  static int
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:312,317 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:311,365
	  	return 1;
	  }
	  
	+ static void
	+ commonboot(Fhdr *fp)
	+ {
	+ 	uvlong kbase;
	+ 
	+ 	kbase = mach->kbase;
	+ 	if ((fp->entry & kbase) != kbase)
	+ 		return;
	+ 
	+ 	switch(fp->type) {				/* boot image */
	+ 	case F68020:
	+ 		fp->type = F68020B;
	+ 		fp->name = "68020 plan 9 boot image";
	+ 		break;
	+ 	case FI386:
	+ 		fp->type = FI386B;
	+ 		fp->txtaddr = (u32int)fp->entry;
	+ 		fp->name = "386 plan 9 boot image";
	+ 		fp->dataddr = _round(fp->txtaddr+fp->txtsz, mach->pgsize);
	+ 		break;
	+ 	case FARM:
	+ 		fp->txtaddr = kbase+0x8010;
	+ 		fp->name = "ARM plan 9 boot image";
	+ 		fp->dataddr = fp->txtaddr+fp->txtsz;
	+ 		return;
	+ 	case FALPHA:
	+ 		fp->type = FALPHAB;
	+ 		fp->txtaddr = (u32int)fp->entry;
	+ 		fp->name = "alpha plan 9 boot image?";
	+ 		fp->dataddr = fp->txtaddr+fp->txtsz;
	+ 		break;
	+ 	case FPOWER:
	+ 		fp->type = FPOWERB;
	+ 		fp->txtaddr = (u32int)fp->entry;
	+ 		fp->name = "power plan 9 boot image";
	+ 		fp->dataddr = fp->txtaddr+fp->txtsz;
	+ 		break;
	+ 	case FAMD64:
	+ 		fp->type = FAMD64B;
	+ 		fp->txtaddr = fp->entry;
	+ 		fp->name = "amd64 plan 9 boot image";
	+ 		fp->dataddr = _round(fp->txtaddr+fp->txtsz, mach->pgsize);
	+ 		break;
	+ 	default:
	+ 		return;
	+ 	}
	+ 	fp->hdrsz = 0;					/* header stripped */
	+ }
	+ 
	  /*
	   *	68020 2.out and 68020 bootable images
	   *	386I 8.out and 386I bootable images
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:321,328 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:369,374
	  static int
	  common(int fd, Fhdr *fp, ExecHdr *hp)
	  {
	- 	long kbase;
	- 
	  	adotout(fd, fp, hp);
	  	if(hp->e.magic & DYN_MAGIC) {
	  		fp->txtaddr = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:329,383 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:375,416
	  		fp->dataddr = fp->txtsz;
	  		return 1;
	  	}
	- 	kbase = mach->kbase;
	- 	if ((fp->entry & kbase) == kbase) {		/* Boot image */
	- 		switch(fp->type) {
	- 		case F68020:
	- 			fp->type = F68020B;
	- 			fp->name = "68020 plan 9 boot image";
	- 			fp->hdrsz = 0;		/* header stripped */
	- 			break;
	- 		case FI386:
	- 			fp->type = FI386B;
	- 			fp->txtaddr = sizeof(Exec);
	- 			fp->name = "386 plan 9 boot image";
	- 			fp->hdrsz = 0;		/* header stripped */
	- 			fp->dataddr = _round(fp->txtaddr+fp->txtsz, mach->pgsize);
	- 			break;
	- 		case FARM:
	- 			fp->txtaddr = kbase+0x8010;
	- 			fp->name = "ARM plan 9 boot image";
	- 			fp->hdrsz = 0;		/* header stripped */
	- 			fp->dataddr = fp->txtaddr+fp->txtsz;
	- 			return 1;
	- 		case FALPHA:
	- 			fp->type = FALPHAB;
	- 			fp->txtaddr = fp->entry;
	- 			fp->name = "alpha plan 9 boot image?";
	- 			fp->hdrsz = 0;		/* header stripped */
	- 			fp->dataddr = fp->txtaddr+fp->txtsz;
	- 			break;
	- 		case FPOWER:
	- 			fp->type = FPOWERB;
	- 			fp->txtaddr = fp->entry;
	- 			fp->name = "power plan 9 boot image";
	- 			fp->hdrsz = 0;		/* header stripped */
	- 			fp->dataddr = fp->txtaddr+fp->txtsz;
	- 			break;
	- 		case FAMD64:
	- 			fp->type = FAMD64B;
	- 			fp->txtaddr = sizeof(Exec);
	- 			fp->name = "amd64 plan 9 boot image";
	- 			fp->hdrsz = 0;		/* header stripped */
	- 			fp->dataddr = _round(fp->txtaddr+fp->txtsz, mach->pgsize);
	- 			break;
	- 		default:
	- 			break;
	- 		}
	- 		fp->txtaddr |= kbase;
	- 		fp->entry |= kbase;
	- 		fp->dataddr |= kbase;
	+ 	commonboot(fp);
	+ 	return 1;
	+ }
	+ 
	+ static int
	+ commonllp64(int, Fhdr *fp, ExecHdr *hp)
	+ {
	+ 	long pgsize;
	+ 	uvlong entry;
	+ 
	+ 	hswal(&hp->e, sizeof(Exec)/sizeof(long), beswal);
	+ 	if(!(hp->e.magic & HDR_MAGIC))
	+ 		return 0;
	+ 
	+ 	/*
	+ 	 * There can be more magic here if the
	+ 	 * header ever needs more expansion.
	+ 	 * For now just catch use of any of the
	+ 	 * unused bits.
	+ 	 */
	+ 	if((hp->e.magic & ~DYN_MAGIC)>>16)
	+ 		return 0;
	+ 	entry = beswav(hp->e.hdr[0]);
	+ 
	+ 	pgsize = mach->pgsize;
	+ 	settext(fp, entry, pgsize+fp->hdrsz, hp->e.text, fp->hdrsz);
	+ 	setdata(fp, _round(pgsize+fp->txtsz+fp->hdrsz, pgsize),
	+ 		hp->e.data, fp->txtsz+fp->hdrsz, hp->e.bss);
	+ 	setsym(fp, hp->e.syms, hp->e.spsz, hp->e.pcsz, fp->datoff+fp->datsz);
	+ 
	+ 	if(hp->e.magic & DYN_MAGIC) {
	+ 		fp->txtaddr = 0;
	+ 		fp->dataddr = fp->txtsz;
	+ 		return 1;
	  	}
	+ 	commonboot(fp);
	  	return 1;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:472,478 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:505,510
	  	return 1;
	  }
	  
	- 
	  /*
	   * Elf32 binaries.
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:480,486 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:512,518
	  elfdotout(int fd, Fhdr *fp, ExecHdr *hp)
	  {
	  
	- 	long (*swal)(long);
	+ 	ulong (*swal)(ulong);
	  	ushort (*swab)(ushort);
	  	Ehdr *ep;
	  	Phdr *ph;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:560,574 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:592,606
	  		free(ph);
	  		return 0;
	  	}
	- 	hswal((long*)ph, phsz/sizeof(long), swal);
	+ 	hswal(ph, phsz/sizeof(ulong), swal);
	  
	  	/* find text, data and symbols and install them */
	  	it = id = is = -1;
	  	for(i = 0; i < ep->phnum; i++) {
	- 		if(ph[i].type == LOAD 
	+ 		if(ph[i].type == LOAD
	  		&& (ph[i].flags & (R|X)) == (R|X) && it == -1)
	  			it = i;
	- 		else if(ph[i].type == LOAD 
	+ 		else if(ph[i].type == LOAD
	  		&& (ph[i].flags & (R|W)) == (R|W) && id == -1)
	  			id = i;
	  		else if(ph[i].type == NOPTYPE && is == -1)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:575,587 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:607,619
	  			is = i;
	  	}
	  	if(it == -1 || id == -1) {
	- 		/* 
	+ 		/*
	  		 * The SPARC64 boot image is something of an ELF hack.
	  		 * Text+Data+BSS are represented by ph[0].  Symbols
	  		 * are represented by ph[1]:
	  		 *
	  		 *		filesz, memsz, vaddr, paddr, off
	- 		 * ph[0] : txtsz+datsz, txtsz+datsz+bsssz, txtaddr-KZERO, datasize,  txtoff
	+ 		 * ph[0] : txtsz+datsz, txtsz+datsz+bsssz, txtaddr-KZERO, datasize, txtoff
	  		 * ph[1] : symsz, lcsz, 0, 0, symoff
	  		 */
	  		if(ep->machine == SPARC64 && ep->phnum == 2) {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:617,623 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:649,655
	  static int
	  alphadotout(int fd, Fhdr *fp, ExecHdr *hp)
	  {
	- 	long kbase;
	+ 	uvlong kbase;
	  
	  	USED(fd);
	  	settext(fp, hp->e.entry, sizeof(Exec), hp->e.text, sizeof(Exec));
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:645,651 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:677,683
	  static int
	  armdotout(int fd, Fhdr *fp, ExecHdr *hp)
	  {
	- 	long kbase;
	+ 	uvlong kbase;
	  
	  	USED(fd);
	  	settext(fp, hp->e.entry, sizeof(Exec), hp->e.text, sizeof(Exec));
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:663,669 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:695,701
	  }
	  
	  static void
	- settext(Fhdr *fp, long e, long a, long s, long off)
	+ settext(Fhdr *fp, uvlong e, uvlong a, long s, vlong off)
	  {
	  	fp->txtaddr = a;
	  	fp->entry = e;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:670,677 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:702,710
	  	fp->txtsz = s;
	  	fp->txtoff = off;
	  }
	+ 
	  static void
	- setdata(Fhdr *fp, long a, long s, long off, long bss)
	+ setdata(Fhdr *fp, uvlong a, long s, vlong off, long bss)
	  {
	  	fp->dataddr = a;
	  	fp->datsz = s;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/executable.c:678,699 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/executable.c:711,733
	  	fp->datoff = off;
	  	fp->bsssz = bss;
	  }
	+ 
	  static void
	- setsym(Fhdr *fp, long sy, long sppc, long lnpc, long symoff)
	+ setsym(Fhdr *fp, long symsz, long sppcsz, long lnpcsz, vlong symoff)
	  {
	- 	fp->symsz = sy;
	+ 	fp->symsz = symsz;
	  	fp->symoff = symoff;
	- 	fp->sppcsz = sppc;
	+ 	fp->sppcsz = sppcsz;
	  	fp->sppcoff = fp->symoff+fp->symsz;
	- 	fp->lnpcsz = lnpc;
	+ 	fp->lnpcsz = lnpcsz;
	  	fp->lnpcoff = fp->sppcoff+fp->sppcsz;
	  }
	  
	  
	- static ulong
	- _round(ulong a, ulong b)
	+ static uvlong
	+ _round(uvlong a, ulong b)
	  {
	- 	ulong w;
	+ 	uvlong w;
	  
	  	w = (a/b)*b;
	  	if (a!=w)
 [rsc] --rw-rw-r-- M 451989 glenda sys 3370 Nov  6 10:02 sys/src/libmach/k.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/k.c:107,114 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/k.c:107,115
	  	"setSB",	/* static base register name */
	  	0,		/* value */
	  	0x1000,		/* page size */
	- 	0xE0000000,	/* kernel base */
	+ 	0xE0000000ULL,	/* kernel base */
	  	0,		/* kernel text mask */
	+ 	0x7FFFFFFFULL,	/* user stack top */
	  	4,		/* quantization of pc */
	  	4,		/* szaddr */
	  	4,		/* szreg */
 [rsc] --rw-rw-r-- M 451989 glenda sys 21161 Nov  6 10:03 sys/src/libmach/kdb.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:8,17 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:8,17
	   */
	  
	  static	char	*sparcexcep(Map*, Rgetter);
	- static	int	sparcfoll(Map*, ulong, Rgetter, ulong*);
	- static	int	sparcinst(Map*, ulong, char, char*, int);
	- static	int	sparcdas(Map*, ulong, char*, int);
	- static	int	sparcinstlen(Map*, ulong);
	+ static	int	sparcfoll(Map*, uvlong, Rgetter, uvlong*);
	+ static	int	sparcinst(Map*, uvlong, char, char*, int);
	+ static	int	sparcdas(Map*, uvlong, char*, int);
	+ static	int	sparcinstlen(Map*, uvlong);
	  
	  Machdata sparcmach =
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:116,122 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:116,122
	  	int	target;		/* SETHI+ADD dest reg */
	  	long	w0;
	  	long	w1;
	- 	ulong	addr;		/* pc of instruction */
	+ 	uvlong	addr;		/* pc of instruction */
	  	char	*curr;		/* current fill level in output buffer */
	  	char	*end;		/* end of buffer */
	  	int 	size;		/* number of longs in instr */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:126,132 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:126,132
	  static	Map	*mymap;		/* disassembler context */
	  static	int	dascase;
	  
	- static int	mkinstr(ulong, Instr*);
	+ static int	mkinstr(uvlong, Instr*);
	  static void	bra1(Instr*, char*, char*[]);
	  static void	bra(Instr*, char*);
	  static void	fbra(Instr*, char*);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:288,296 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:288,296
	  }
	  
	  static int
	- decode(ulong pc, Instr *i)
	+ decode(uvlong pc, Instr *i)
	  {
	- 	long w;
	+ 	ulong w;
	  
	  	if (get4(mymap, pc, &w) < 0) {
	  		werrstr("can't read instruction: %r");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:323,329 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:323,329
	  }
	  
	  static int
	- mkinstr(ulong pc, Instr *i)
	+ mkinstr(uvlong pc, Instr *i)
	  {
	  	Instr xi;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:354,360 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:354,360
	  }
	  
	  static int
	- printins(Map *map, ulong pc, char *buf, int n)
	+ printins(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr instr;
	  	void (*f)(Instr*, char*);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:424,430 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:424,430
	  }
	  
	  static int
	- sparcinst(Map *map, ulong pc, char modifier, char *buf, int n)
	+ sparcinst(Map *map, uvlong pc, char modifier, char *buf, int n)
	  {
	  	static int fmtinstalled = 0;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:442,448 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:442,448
	  }
	  
	  static int
	- sparcdas(Map *map, ulong pc, char *buf, int n)
	+ sparcdas(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr instr;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:463,469 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:463,469
	  }
	  
	  static int
	- sparcinstlen(Map *map, ulong pc)
	+ sparcinstlen(Map *map, uvlong pc)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:500,506 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:500,506
	  address(Instr *i)
	  {
	  	Symbol s, s2;
	- 	long off, off1;
	+ 	uvlong off, off1;
	  
	  	if (i->rs1 == 1 && plocal(i) >= 0)
	  		return;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:510,516 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:510,516
	  			&& (s.class == CDATA || s.class == CTEXT)) {
	  		if(off==s.value && s.name[0]=='$'){
	  			off1 = 0;
	- 			get4(mymap, s.value, &off1);
	+ 			geta(mymap, s.value, &off1);
	  			if(off1 && findsym(off1, CANY, &s2) && s2.value == off1){
	  				bprint(i, "$%s(SB)", s2.name);
	  				return;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:878,885 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:878,885
	  		bprint(i, ", R%d", i->rd);
	  }
	  
	- static
	- void storef(Instr *i, char *m)		/* page 70 */
	+ static void
	+ storef(Instr *i, char *m)		/* page 70 */
	  {
	  	if(!dascase){
	  		m = "FMOVD";
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:901,908 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:901,908
	  		address(i);
	  }
	  
	- static
	- void loadc(Instr *i, char *m)			/* page 72 */
	+ static void
	+ loadc(Instr *i, char *m)			/* page 72 */
	  {
	  	if(i->i == 0)
	  		bprint(i, "%s\t(R%d+R%d), C%d", m, i->rs1, i->rs2, i->rd);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:913,920 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:913,920
	  	}
	  }
	  
	- static
	- void loadcsr(Instr *i, char *m)			/* page 72 */
	+ static void
	+ loadcsr(Instr *i, char *m)			/* page 72 */
	  {
	  	if(i->i == 0)
	  		bprint(i, "%s\t(R%d+R%d), CSR", m, i->rs1, i->rs2);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/kdb.c:1007,1013 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/kdb.c:1007,1013
	  }
	  
	  static int
	- sparcfoll(Map *map, ulong pc, Rgetter rget, ulong *foll)
	+ sparcfoll(Map *map, uvlong pc, Rgetter rget, uvlong *foll)
	  {
	  	ulong w, r1, r2;
	  	char buf[8];
 [rsc] --rw-rw-r-- M 451989 glenda sys 8799 Nov  6 10:02 sys/src/libmach/machdata.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:17,27 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:17,26
	  Machdata *machdata;		/* machine-dependent functions */
	  
	  int
	- localaddr(Map *map, char *fn, char *var, long *r, Rgetter rget)
	+ localaddr(Map *map, char *fn, char *var, uvlong *r, Rgetter rget)
	  {
	  	Symbol s;
	- 	ulong fp;
	- 	ulong pc, sp, link;
	+ 	uvlong fp, pc, sp, link;
	  
	  	if (!lookup(fn, 0, &s)) {
	  		werrstr("function not found");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:64,73 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:63,72
	  }
	  
	  /*
	-  * Print value v as name[+offset] and then the string s.
	+  * Print value v as s.name[+offset] if possible, or just v.
	   */
	  int
	- symoff(char *buf, int n, long v, int space)
	+ symoff(char *buf, int n, uvlong v, int space)
	  {
	  	Symbol s;
	  	int r;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:82,95 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:81,95
	  			delta = -delta;
	  	}
	  	if (v == 0 || r == 0)
	- 		return snprint(buf, n, "%lux", v);
	+ 		return snprint(buf, n, "%llux", v);
	  	if (s.type != 't' && s.type != 'T' && delta >= 4096)
	- 		return snprint(buf, n, "%lux", v);
	+ 		return snprint(buf, n, "%llux", v);
	  	else if (delta)
	  		return snprint(buf, n, "%s+%lux", s.name, delta);
	  	else
	  		return snprint(buf, n, "%s", s.name);
	  }
	+ 
	  /*
	   *	Format floating point registers
	   *
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:104,110 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:104,110
	  fpformat(Map *map, Reglist *rp, char *buf, int n, int modif)
	  {
	  	char reg[12];
	- 	long r;
	+ 	ulong r;
	  
	  	switch(rp->rformat)
	  	{
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:317,323 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:317,322
	  	return beieeedftos(buf, n, (void*)ieee);
	  }
	  
	- 
	  int
	  leieee80ftos(char *buf, int n, void *s)
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:332,350 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:331,348
	  }
	  
	  int
	- cisctrace(Map *map, ulong pc, ulong sp, ulong link, Tracer trace)
	+ cisctrace(Map *map, uvlong pc, uvlong sp, uvlong link, Tracer trace)
	  {
	  	Symbol s;
	- 	int found;
	- 	ulong opc;
	- 	long moved, j;
	+ 	int found, i;
	+ 	uvlong opc, moved;
	  
	  	USED(link);
	- 	j = 0;
	+ 	i = 0;
	  	opc = 0;
	  	while(pc && opc != pc) {
	  		moved = pc2sp(pc);
	- 		if (moved == -1)
	+ 		if (moved == ~0)
	  			break;
	  		found = findsym(pc, CTEXT, &s);
	  		if (!found)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:354,375 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:352,373
	  
	  		sp += moved;
	  		opc = pc;
	- 		if (get4(map, sp, (long *)&pc) < 0)
	+ 		if (geta(map, sp, &pc) < 0)
	  			break;
	  		(*trace)(map, pc, sp, &s);
	  		sp += mach->szaddr;	/*assumes address size = stack width*/
	- 		if(++j > 40)
	+ 		if(++i > 40)
	  			break;
	  	}
	- 	return j;
	+ 	return i;
	  }
	  
	  int
	- risctrace(Map *map, ulong pc, ulong sp, ulong link, Tracer trace)
	+ risctrace(Map *map, uvlong pc, uvlong sp, uvlong link, Tracer trace)
	  {
	  	int i;
	  	Symbol s, f;
	- 	ulong oldpc;
	+ 	uvlong oldpc;
	  
	  	i = 0;
	  	while(findsym(pc, CTEXT, &s)) {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:385,391 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:383,389
	  		if(s.type == 'L' || s.type == 'l' || pc <= s.value+mach->pcquant)
	  			pc = link;
	  		else
	- 			if (get4(map, sp, (long *) &pc) < 0)
	+ 			if (geta(map, sp, &pc) < 0)
	  				break;
	  
	  		if(pc == 0 || (pc == oldpc && f.value == 0))
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:400,421 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:398,419
	  	return i;
	  }
	  
	- ulong
	- ciscframe(Map *map, ulong addr, ulong pc, ulong sp, ulong link)
	+ uvlong
	+ ciscframe(Map *map, uvlong addr, uvlong pc, uvlong sp, uvlong link)
	  {
	  	Symbol s;
	- 	int moved;
	+ 	uvlong moved;
	  
	  	USED(link);
	  	for(;;) {
	  		moved = pc2sp(pc);
	- 		if (moved  == -1)
	+ 		if (moved  == ~0)
	  			break;
	  		sp += moved;
	  		findsym(pc, CTEXT, &s);
	  		if (addr == s.value)
	  			return sp;
	- 		if (get4(map, sp, (long *) &pc) < 0)
	+ 		if (geta(map, sp, &pc) < 0)
	  			break;
	  		sp += mach->szaddr;	/*assumes sizeof(addr) = stack width*/
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:422,429 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:420,427
	  	return 0;
	  }
	  
	- ulong
	- riscframe(Map *map, ulong addr, ulong pc, ulong sp, ulong link)
	+ uvlong
	+ riscframe(Map *map, uvlong addr, uvlong pc, uvlong sp, uvlong link)
	  {
	  	Symbol s, f;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/machdata.c:444,450 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/machdata.c:442,448
	  		if (s.type == 'L' || s.type == 'l' || pc-s.value <= mach->szaddr*2)
	  			pc = link;
	  		else
	- 		if (get4(map, sp-f.value, (long *)&pc) < 0)
	+ 		if (geta(map, sp-f.value, &pc) < 0)
	  			break;
	  	}
	  	return 0;
 [rsc] --rw-rw-r-- M 451989 glenda sys 3056 Nov  6 10:02 sys/src/libmach/map.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:26,32 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:26,32
	  }
	  
	  int
	- setmap(Map *map, int fd, ulong b, ulong e, ulong f, char *name)
	+ setmap(Map *map, int fd, uvlong b, uvlong e, vlong f, char *name)
	  {
	  	int i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:46,52 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:46,52
	  	return 1;
	  }
	  
	- static ulong
	+ static uvlong
	  stacktop(int pid)
	  {
	  	char buf[64];
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:54,60 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:54,60
	  	int n;
	  	char *cp;
	  
	- 	sprint(buf, "/proc/%d/segment", pid);
	+ 	snprint(buf, sizeof(buf), "/proc/%d/segment", pid);
	  	fd = open(buf, 0);
	  	if (fd < 0)
	  		return 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:74,80 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:74,80
	  		cp++;
	  	if (!*cp)
	  		return 0;
	- 	return strtoul(cp, 0, 16);
	+ 	return strtoull(cp, 0, 16);
	  }
	  
	  Map*
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:83,89 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:83,89
	  	char buf[64], *regs;
	  	int fd;
	  	Map *map;
	- 	ulong n;
	+ 	uvlong n;
	  	int mode;
	  
	  	map = newmap(0, 4);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/map.c:116,128 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/map.c:116,128
	  		setmap(map, fd, mach->regsize, mach->regsize+mach->fpregsize, 0, "fpregs");
	  	}
	  	setmap(map, corefd, fp->txtaddr, fp->txtaddr+fp->txtsz, fp->txtaddr, "text");
	- 	if(kflag || (ulong) fp->dataddr >= 0x7fffffff) {
	- 		setmap(map, corefd, fp->dataddr, 0xffffffff, fp->dataddr, "data");
	+ 	if(kflag || fp->dataddr >= mach->utop) {
	+ 		setmap(map, corefd, fp->dataddr, ~0, fp->dataddr, "data");
	  		return map;
	  	}
	  	n = stacktop(pid);
	  	if (n == 0) {
	- 		setmap(map, corefd, fp->dataddr, 0x7fffffff, fp->dataddr, "data");
	+ 		setmap(map, corefd, fp->dataddr, mach->utop, fp->dataddr, "data");
	  		return map;
	  	}
	  	setmap(map, corefd, fp->dataddr, n, fp->dataddr, "data");
 [rsc] --rw-rw-r-- M 451989 glenda sys 5929 Nov  6 10:02 sys/src/libmach/obj.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/obj.c:127,133 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/obj.c:127,133
	  }
	  
	  int
	- readar(Biobuf *bp, int objtype, int end, int doautos)
	+ readar(Biobuf *bp, int objtype, vlong end, int doautos)
	  {
	  	Prog p;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/obj.c:253,259 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/obj.c:253,259
	   * update the offset information for a 'a' or 'p' symbol in an intermediate file
	   */
	  void
	- _offset(int id, long off)
	+ _offset(int id, vlong off)
	  {
	  	Sym *s;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/obj.c:299,305 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/obj.c:299,305
	  	for(i=0; i<sizeof(a.name) && i<SARNAME && a.name[i] != ' '; i++)
	  		buf[i] = a.name[i];
	  	buf[i] = 0;
	- 	arsize = atol(a.size);
	+ 	arsize = strtol(a.size, 0, 0);
	  	if (arsize&1)
	  		arsize++;
	  	return arsize + SAR_HDR;
 [rsc] --rw-rw-r-- M 451989 glenda sys 3630 Nov  6 10:02 sys/src/libmach/q.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/q.c:112,119 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/q.c:112,120
	  	"setSB",	/* static base register name */
	  	0,		/* value */
	  	0x1000,		/* page size */
	- 	0x80000000,	/* kernel base */
	+ 	0x80000000ULL,	/* kernel base */
	  	0,		/* kernel text mask */
	+ 	0x7FFFFFFFULL,	/* user stack top */
	  	4,		/* quantization of pc */
	  	4,		/* szaddr */
	  	4,		/* szreg */
 [rsc] --rw-rw-r-- M 451989 glenda sys 27506 Nov  6 10:03 sys/src/libmach/qdb.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:9,18 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:9,18
	   */
	  
	  static	char	*powerexcep(Map*, Rgetter);
	- static	int	powerfoll(Map*, ulong, Rgetter, ulong*);
	- static	int	powerinst(Map*, ulong, char, char*, int);
	- static	int	powerinstlen(Map*, ulong);
	- static	int	powerdas(Map*, ulong, char*, int);
	+ static	int	powerfoll(Map*, uvlong, Rgetter, uvlong*);
	+ static	int	powerinst(Map*, uvlong, char, char*, int);
	+ static	int	powerinstlen(Map*, uvlong);
	+ static	int	powerdas(Map*, uvlong, char*, int);
	  
	  /*
	   *	Machine description
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:146,152 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:146,152
	  	long	immediate;
	  	long w0;
	  	long w1;
	- 	ulong	addr;		/* pc of instruction */
	+ 	uvlong	addr;		/* pc of instruction */
	  	short	target;
	  	char	*curr;		/* current fill level in output buffer */
	  	char	*end;		/* end of buffer */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:168,176 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:168,176
	  }
	  
	  static int
	- decode(ulong pc, Instr *i)
	+ decode(uvlong pc, Instr *i)
	  {
	- 	long w;
	+ 	ulong w;
	  
	  	if (get4(mymap, pc, &w) < 0) {
	  		werrstr("can't read instruction: %r");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:224,230 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:224,230
	  }
	  
	  static int
	- mkinstr(ulong pc, Instr *i)
	+ mkinstr(uvlong pc, Instr *i)
	  {
	  	Instr x;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:271,280 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:271,280
	  }
	  
	  static int
	- pglobal(Instr *i, long off, int anyoff, char *reg)
	+ pglobal(Instr *i, uvlong off, int anyoff, char *reg)
	  {
	  	Symbol s, s2;
	- 	long off1;
	+ 	uvlong off1;
	  
	  	if(findsym(off, CANY, &s) &&
	  	   s.value-off < 4096 &&
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:281,287 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:281,287
	  	   (s.class == CDATA || s.class == CTEXT)) {
	  		if(off==s.value && s.name[0]=='$'){
	  			off1 = 0;
	- 			get4(mymap, s.value, &off1);
	+ 			geta(mymap, s.value, &off1);
	  			if(off1 && findsym(off1, CANY, &s2) && s2.value == off1){
	  				bprint(i, "$%s%s", s2.name, reg);
	  				return 1;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:696,703 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:696,703
	  
	  	{31,	28,	ALL,	"AND%C",	and,	il3},
	  	{31,	60,	ALL,	"ANDN%C",	and,	il3},
	- 	{28,	0,	0,	"ANDCC",		andi,	il2u},
	- 	{29,	0,	0,	"ANDCC",		shifted, 0},
	+ 	{28,	0,	0,	"ANDCC",	andi,	il2u},
	+ 	{29,	0,	0,	"ANDCC",	shifted, 0},
	  
	  	{18,	0,	0,	"B%L",		gencc,	"%j"},
	  	{16,	0,	0,	"BC%L",		branch,	"%d,%a,%J"},
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:798,809 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:798,809
	  	{41,	0,	0,	"MOVHZU",	load,	ldop},
	  	{31,	311,	ALL,	"MOVHZU",	ldx,	0},
	  	{31,	279,	ALL,	"MOVHZ",	ldx,	0},
	- 	{46,	0,	0,	"MOVMW",		load,	ldop},
	+ 	{46,	0,	0,	"MOVMW",	load,	ldop},
	  	{31,	277,	ALL,	"LSCBX%C",	ldx,	0},	/* POWER */
	  	{31,	597,	ALL,	"LSW",		gen,	"(R%a),$%n,R%d"},
	  	{31,	533,	ALL,	"LSW",		ldx,	0},
	  	{31,	20,	ALL,	"LWAR",		ldx,	0},
	- 	{31,	534,	ALL,	"MOVWBR",		ldx,	0},
	+ 	{31,	534,	ALL,	"MOVWBR",	ldx,	0},
	  	{32,	0,	0,	"MOVW",		load,	ldop},
	  	{33,	0,	0,	"MOVWU",	load,	ldop},
	  	{31,	55,	ALL,	"MOVWU",	ldx,	0},
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:814,821 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:814,821
	  
	  	{19,	0,	ALL,	"MOVFL",	gen,	"%S,%D"},
	  	{63,	64,	ALL,	"MOVCRFS",	gen,	"%S,%D"},
	- 	{31,	512,	ALL,	"MOVW",	gen,	"XER,%D"},
	- 	{31,	19,	ALL,	"MOVW",	gen,	"CR,R%d"},
	+ 	{31,	512,	ALL,	"MOVW",		gen,	"XER,%D"},
	+ 	{31,	19,	ALL,	"MOVW",		gen,	"CR,R%d"},
	  
	  	{63,	583,	ALL,	"MOVW%C",	gen,	"FPSCR, F%d"},	/* mffs */
	  	{31,	83,	ALL,	"MOVW",		gen,	"MSR,R%d"},
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:822,828 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:822,828
	  	{31,	339,	ALL,	"MOVW",		gen,	"%P,R%d"},
	  	{31,	595,	ALL,	"MOVW",		gen,	"SEG(%a),R%d"},
	  	{31,	659,	ALL,	"MOVW",		gen,	"SEG(R%b),R%d"},
	- 	{31,	323,	ALL,	"MOVW",		gen, "DCR(%Q),R%d"},
	+ 	{31,	323,	ALL,	"MOVW",		gen,	"DCR(%Q),R%d"},
	  	{31,	451,	ALL,	"MOVW",		gen,	"R%s,DCR(%Q)"},
	  	{31,	144,	ALL,	"MOVFL",	gen,	"R%s,%m,CR"},
	  	{63,	70,	ALL,	"MTFSB0%C",	gencc,	"%D"},
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:846,852 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:846,852
	  	{31,	476,	ALL,	"NAND%C",	gencc,	il3},
	  	{31,	104,	OEM,	"NEG%V%C",	neg,	ir2},
	  	{31,	124,	ALL,	"NOR%C",	gencc,	il3},
	- 	{31,	444,	ALL,	"OR%C",	or,	il3},
	+ 	{31,	444,	ALL,	"OR%C",		or,	il3},
	  	{31,	412,	ALL,	"ORN%C",	or,	il3},
	  	{24,	0,	0,	"OR",		and,	"%I,R%d,R%a"},
	  	{25,	0,	0,	"OR",		shifted, 0},
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:905,916 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:905,916
	  	{45,	0,	0,	"MOVHU",	store,	stop},
	  	{31,	439,	ALL,	"MOVHU",	stx,	0},
	  	{31,	407,	ALL,	"MOVH",		stx,	0},
	- 	{47,	0,	0,	"MOVMW",		store,	stop},
	+ 	{47,	0,	0,	"MOVMW",	store,	stop},
	  	{31,	725,	ALL,	"STSW",		gen,	"R%d,$%n,(R%a)"},
	  	{31,	661,	ALL,	"STSW",		stx,	0},
	  	{36,	0,	0,	"MOVW",		store,	stop},
	  	{31,	662,	ALL,	"MOVWBR",	stx,	0},
	- 	{31,	150,	ALL,	"STWCCC",		stx,	0},
	+ 	{31,	150,	ALL,	"STWCCC",	stx,	0},
	  	{37,	0,	0,	"MOVWU",	store,	stop},
	  	{31,	183,	ALL,	"MOVWU",	stx,	0},
	  	{31,	151,	ALL,	"MOVW",		stx,	0},
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:1153,1159 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:1153,1159
	  }
	  
	  static int
	- printins(Map *map, ulong pc, char *buf, int n)
	+ printins(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr i;
	  	Opcode *o;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:1177,1183 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:1177,1183
	  }
	  
	  static int
	- powerinst(Map *map, ulong pc, char modifier, char *buf, int n)
	+ powerinst(Map *map, uvlong pc, char modifier, char *buf, int n)
	  {
	  	USED(modifier);
	  	return printins(map, pc, buf, n);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:1184,1190 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:1184,1190
	  }
	  
	  static int
	- powerdas(Map *map, ulong pc, char *buf, int n)
	+ powerdas(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr instr;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:1205,1211 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:1205,1211
	  }
	  
	  static int
	- powerinstlen(Map *map, ulong pc)
	+ powerinstlen(Map *map, uvlong pc)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/qdb.c:1216,1222 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/qdb.c:1216,1222
	  }
	  
	  static int
	- powerfoll(Map *map, ulong pc, Rgetter rget, ulong *foll)
	+ powerfoll(Map *map, uvlong pc, Rgetter rget, uvlong *foll)
	  {
	  	char *reg;
	  	Instr i;
 [rsc] --rw-rw-r-- M 451989 glenda sys 1056 Nov  6 10:02 sys/src/libmach/swap.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/swap.c:15,22 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/swap.c:15,22
	  /*
	   * big-endian long
	   */
	- long
	- beswal(long l)
	+ ulong
	+ beswal(ulong l)
	  {
	  	uchar *p;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/swap.c:27,42 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/swap.c:27,42
	  /*
	   * big-endian vlong
	   */
	- vlong
	- beswav(vlong v)
	+ uvlong
	+ beswav(uvlong v)
	  {
	  	uchar *p;
	  
	  	p = (uchar*)&v;
	- 	return ((vlong)p[0]<<56) | ((vlong)p[1]<<48) | ((vlong)p[2]<<40)
	- 				 | ((vlong)p[3]<<32) | ((vlong)p[4]<<24)
	- 				 | ((vlong)p[5]<<16) | ((vlong)p[6]<<8)
	- 				 | (vlong)p[7];
	+ 	return ((uvlong)p[0]<<56) | ((uvlong)p[1]<<48) | ((uvlong)p[2]<<40)
	+ 				  | ((uvlong)p[3]<<32) | ((uvlong)p[4]<<24)
	+ 				  | ((uvlong)p[5]<<16) | ((uvlong)p[6]<<8)
	+ 				  | (uvlong)p[7];
	  }
	  
	  /*
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/swap.c:54,61 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/swap.c:54,61
	  /*
	   * little-endian long
	   */
	- long
	- leswal(long l)
	+ ulong
	+ leswal(ulong l)
	  {
	  	uchar *p;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/swap.c:66,79 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/swap.c:66,79
	  /*
	   * little-endian vlong
	   */
	- vlong
	- leswav(vlong v)
	+ uvlong
	+ leswav(uvlong v)
	  {
	  	uchar *p;
	  
	  	p = (uchar*)&v;
	- 	return ((vlong)p[7]<<56) | ((vlong)p[6]<<48) | ((vlong)p[5]<<40)
	- 				 | ((vlong)p[4]<<32) | ((vlong)p[3]<<24)
	- 				 | ((vlong)p[2]<<16) | ((vlong)p[1]<<8)
	- 				 | (vlong)p[0];
	+ 	return ((uvlong)p[7]<<56) | ((uvlong)p[6]<<48) | ((uvlong)p[5]<<40)
	+ 				  | ((uvlong)p[4]<<32) | ((uvlong)p[3]<<24)
	+ 				  | ((uvlong)p[2]<<16) | ((uvlong)p[1]<<8)
	+ 				  | (uvlong)p[0];
	  }
 [rsc] --rw-rw-r-- M 451989 glenda sys 26729 Nov  6 10:02 sys/src/libmach/sym.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:16,22 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:16,22
	  	Sym	*sym;			/* function symbol entry */
	  };
	  
	- struct hist {		/* Stack of include files & #line directives */
	+ struct hist {				/* Stack of include files & #line directives */
	  	char	*name;			/* Assumes names Null terminated in file */
	  	long	line;			/* line # where it was included */
	  	long	offset;			/* line # of #line directive */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:23,35 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:23,35
	  };
	  
	  struct file {				/* Per input file header to history stack */
	- 	long		addr;		/* address of first text sym */
	+ 	uvlong	addr;			/* address of first text sym */
	  	union {
	- 		Txtsym		*txt;	/* first text symbol */
	- 		Sym		*sym;	/* only during initilization */
	+ 		Txtsym	*txt;		/* first text symbol */
	+ 		Sym	*sym;		/* only during initilization */
	  	};
	- 	int		n;		/* size of history stack */
	- 	Hist		*hist;		/* history stack */
	+ 	int	n;			/* size of history stack */
	+ 	Hist	*hist;			/* history stack */
	  };
	  
	  static	int	debug = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:53,63 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:53,63
	  static	uchar	*spoffend;		/* end of pc-sp offset table */
	  static	Sym	*symbols;		/* symbol table */
	  static	Txtsym	*txt;			/* Base of text symbol table */
	- static	long	txtstart;		/* start of text segment */
	- static	long	txtend;			/* end of text segment */
	+ static	uvlong	txtstart;		/* start of text segment */
	+ static	uvlong	txtend;			/* end of text segment */
	  
	  static void	cleansyms(void);
	- static int	decodename(Biobuf*, Sym*);
	+ static long	decodename(Biobuf*, Sym*);
	  static short	*encfname(char*);
	  static int 	fline(char*, int, long, Hist*, Hist**);
	  static void	fillsym(Sym*, Symbol*);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:65,71 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:65,71
	  static int	findlocvar(Symbol*, char *, Symbol*);
	  static int	findtext(char*, Symbol*);
	  static int	hcomp(Hist*, short*);
	- static int	hline(File*, short*, ulong*);
	+ static int	hline(File*, short*, long*);
	  static void	printhist(char*, Hist*, int);
	  static int	buildtbls(void);
	  static int	symcomp(void*, void*);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:80,87 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:80,89
	  syminit(int fd, Fhdr *fp)
	  {
	  	Sym *p;
	- 	int i, size;
	+ 	long i, l, size;
	+ 	vlong vl;
	  	Biobuf b;
	+ 	int svalsz;
	  
	  	if(fp->symsz == 0)
	  		return 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:101,109 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:103,120
	  	nsym = 0;
	  	size = 0;
	  	for(p = symbols; size < fp->symsz; p++, nsym++) {
	- 		if(Bread(&b, &p->value, sizeof(p->value)) != sizeof(p->value))
	- 			return symerrmsg(sizeof(p->value), "symbol");
	- 		p->value = beswal(p->value);
	+ 		if(fp->magic & HDR_MAGIC){
	+ 			svalsz = 8;
	+ 			if(Bread(&b, &vl, 8) != 8)
	+ 				return symerrmsg(8, "symbol");
	+ 			p->value = beswav(vl);
	+ 		}
	+ 		else{
	+ 			svalsz = 4;
	+ 			if(Bread(&b, &l, 4) != 4)
	+ 				return symerrmsg(4, "symbol");
	+ 			p->value = (u32int)beswal(l);
	+ 		}
	  		if(Bread(&b, &p->type, sizeof(p->type)) != sizeof(p->type))
	  			return symerrmsg(sizeof(p->value), "symbol");
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:110,116 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:121,127
	  		i = decodename(&b, p);
	  		if(i < 0)
	  			return -1;
	- 		size += i+sizeof(p->value)+sizeof(p->type);
	+ 		size += i+svalsz+sizeof(p->type);
	  
	  		/* count global & auto vars, text symbols, and file names */
	  		switch (p->type) {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:159,166 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:170,176
	  			return -1;
	  		}
	  		Bseek(&b, fp->sppcoff, 0);
	- 		i = Bread(&b, spoff, fp->sppcsz);
	- 		if(i != fp->sppcsz){
	+ 		if(Bread(&b, spoff, fp->sppcsz) != fp->sppcsz){
	  			spoff = 0;
	  			return symerrmsg(fp->sppcsz, "sp-pc");
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:173,180 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:183,189
	  			return -1;
	  		}
	  		Bseek(&b, fp->lnpcoff, 0);
	- 		i = Bread(&b, pcline, fp->lnpcsz);
	- 		if(i != fp->lnpcsz){
	+ 		if(Bread(&b, pcline, fp->lnpcsz) != fp->lnpcsz){
	  			pcline = 0;
	  			return symerrmsg(fp->lnpcsz, "pc-line");
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:190,201 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:199,211
	  	return -1;
	  }
	  
	- static int
	+ static long
	  decodename(Biobuf *bp, Sym *p)
	  {
	  	char *cp;
	  	int c1, c2;
	- 	int n;
	+ 	long n;
	+ 	vlong o;
	  
	  	if((p->type & 0x80) == 0) {		/* old-style, fixed length names */
	  		p->name = malloc(NNAME);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:211,217 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:221,227
	  
	  	p->type &= ~0x80;
	  	if(p->type == 'z' || p->type == 'Z') {
	- 		n = Bseek(bp, 0, 1);
	+ 		o = Bseek(bp, 0, 1);
	  		if(Bgetc(bp) < 0) {
	  			werrstr("can't read symbol name");
	  			return -1;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:226,240 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:236,250
	  			if(c1 == 0 && c2 == 0)
	  				break;
	  		}
	- 		n = Bseek(bp, 0, 1)-n;
	+ 		n = Bseek(bp, 0, 1)-o;
	  		p->name = malloc(n);
	  		if(p->name == 0) {
	- 			werrstr("can't malloc %d bytes", n);
	+ 			werrstr("can't malloc %ld bytes", n);
	  			return -1;
	  		}
	  		Bseek(bp, -n, 1);
	  		if(Bread(bp, p->name, n) != n) {
	- 			werrstr("can't read %d bytes of symbol name", n);
	+ 			werrstr("can't read %ld bytes of symbol name", n);
	  			return -1;
	  		}
	  	} else {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:246,252 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:256,262
	  		n = Blinelen(bp);
	  		p->name = malloc(n);
	  		if(p->name == 0) {
	- 			werrstr("can't malloc %d bytes", n);
	+ 			werrstr("can't malloc %ld bytes", n);
	  			return -1;
	  		}
	  		strcpy(p->name, cp);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:253,258 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:263,269
	  	}
	  	return n;
	  }
	+ 
	  /*
	   *	free any previously loaded symbol tables
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:296,310 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:307,323
	  		free(pcline);
	  	pcline = 0;
	  }
	+ 
	  /*
	   *	delimit the text segment
	   */
	  void
	- textseg(ulong base, Fhdr *fp)
	+ textseg(uvlong base, Fhdr *fp)
	  {
	  	txtstart = base;
	  	txtend = base+fp->txtsz;
	  }
	+ 
	  /*
	   *	symbase: return base and size of raw symbol table
	   *		(special hack for high access rate operations)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:315,320 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:328,334
	  	*n = nsym;
	  	return symbols;
	  }
	+ 
	  /*
	   *	Get the ith symbol table entry
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:332,338 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:346,353
	  static int
	  buildtbls(void)
	  {
	- 	int i, j, nh, ng, nt;
	+ 	long i;
	+ 	int j, nh, ng, nt;
	  	File *f;
	  	Txtsym *tp;
	  	Hist *hp;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:391,397 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:406,412
	  		case 'B':
	  		case 'b':
	  			if(debug)
	- 				print("Global: %s %lux\n", p->name, p->value);
	+ 				print("Global: %s %llux\n", p->name, p->value);
	  			globals[ng++] = p;
	  			break;
	  		case 'z':
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:430,436 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:445,451
	  			tp->sym = p;
	  			tp->locals = ap;
	  			if(debug)
	- 				print("TEXT: %s at %lux\n", p->name, p->value);
	+ 				print("TEXT: %s at %llux\n", p->name, p->value);
	  			if(f && !f->sym) {			/* first  */
	  				f->sym = p;
	  				f->addr = p->value;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:444,450 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:459,465
	  					p->name);
	  			else {
	  				if(debug)
	- 					print("Local: %s %lux\n", p->name, p->value);
	+ 					print("Local: %s %llux\n", p->name, p->value);
	  				tp->locals[tp->n] = p;
	  				tp->n++;
	  				ap++;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:468,474 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:483,489
	  		for(j = 0; j < ntxt; j++) {
	  			if(f->sym == tp->sym) {
	  				if(debug) {
	- 					print("LINK: %s to at %lux", f->sym->name, f->addr);
	+ 					print("LINK: %s to at %llux", f->sym->name, f->addr);
	  					printhist("... ", f->hist, 1);
	  				}
	  				f->txt = tp++;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:511,516 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:526,532
	  	return findglobal(var, s);		/* case 3: var not found */
	  
	  }
	+ 
	  /*
	   * find a function by name
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:535,541 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:551,557
	  static int
	  findglobal(char *name, Symbol *s)
	  {
	- 	int i;
	+ 	long i;
	  
	  	for(i = 0; i < nglob; i++) {
	  		if(strcmp(globals[i]->name, name) == 0) {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:546,551 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:562,568
	  	}
	  	return 0;
	  }
	+ 
	  /*
	   *	find the local variable by name within a given function
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:558,563 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:575,581
	  		return 0;
	  	return findlocvar(s1, name, s2);
	  }
	+ 
	  /*
	   *	find the local variable by name within a given function
	   *		(internal function - does no parameter validation)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:580,585 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:598,604
	  	}
	  	return 0;
	  }
	+ 
	  /*
	   *	Get ith text symbol
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:596,601 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:615,621
	  	s->index = index;
	  	return 1;
	  }
	+ 
	  /*	
	   *	Get ith file name
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:613,618 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:633,639
	  		return 0;
	  	return fileelem(fnames, (uchar*)hp->name, buf, n);
	  }
	+ 
	  /*
	   *	Lookup name of local variable located at an offset into the frame.
	   *	The type selects either a parameter or automatic.
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:653,661 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:674,682
	   * Find text symbol containing addr; binary search assumes text array is sorted by addr
	   */
	  static int
	- srchtext(long addr)
	+ srchtext(uvlong addr)
	  {
	- 	ulong val;
	+ 	uvlong val;
	  	int top, bot, mid;
	  	Sym *sp;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:664,672 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:685,693
	  	top = ntxt;
	  	for (mid = (bot+top)/2; mid < top; mid = (bot+top)/2) {
	  		sp = txt[mid].sym;
	- 		if(val < (ulong)sp->value)
	+ 		if(val < sp->value)
	  			top = mid;
	- 		else if(mid != ntxt-1 && val >= (ulong)txt[mid+1].sym->value)
	+ 		else if(mid != ntxt-1 && val >= txt[mid+1].sym->value)
	  			bot = mid;
	  		else
	  			return mid;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:677,686 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:698,707
	  /*
	   * Find data symbol containing addr; binary search assumes data array is sorted by addr
	   */
	- static
	- int srchdata(long addr)
	+ static int
	+ srchdata(uvlong addr)
	  {
	- 	ulong val;
	+ 	uvlong val;
	  	int top, bot, mid;
	  	Sym *sp;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:689,697 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:710,718
	  	val = addr;
	  	for(mid = (bot+top)/2; mid < top; mid = (bot+top)/2) {
	  		sp = globals[mid];
	- 		if(val < (ulong)sp->value)
	+ 		if(val < sp->value)
	  			top = mid;
	- 		else if(mid < nglob-1 && val >= (ulong)globals[mid+1]->value)
	+ 		else if(mid < nglob-1 && val >= globals[mid+1]->value)
	  			bot = mid;
	  		else
	  			return mid;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:698,703 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:719,725
	  	}
	  	return -1;
	  }
	+ 
	  /*
	   * Find symbol containing val in specified search space
	   * There is a special case when a value falls beyond the end
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:706,712 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:728,734
	   * data space are searched for a match.
	   */
	  int
	- findsym(long w, int type, Symbol *s)
	+ findsym(uvlong val, int type, Symbol *s)
	  {
	  	int i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:714,720 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:736,742
	  		return 0;
	  
	  	if(type == CTEXT || type == CANY) {
	- 		i = srchtext(w);
	+ 		i = srchtext(val);
	  		if(i >= 0) {
	  			if(type == CTEXT || i != ntxt-1) {
	  				fillsym(txt[i].sym, s);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:725,731 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:747,753
	  		}
	  	}
	  	if(type == CDATA || type == CANY) {
	- 		i = srchdata(w);
	+ 		i = srchdata(val);
	  		if(i >= 0) {
	  			fillsym(globals[i], s);
	  			s->index = i;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:739,745 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:761,767
	   *	Find the start and end address of the function containing addr
	   */
	  int
	- fnbound(long addr, ulong *bounds)
	+ fnbound(uvlong addr, uvlong *bounds)
	  {
	  	int i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:779,784 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:801,807
	  	}
	  	return 0;
	  }
	+ 
	  /*
	   * get the ith global symbol
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:797,820 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:820,843
	  	}
	  	return 0;
	  }
	+ 
	  /*
	   *	find the pc given a file name and line offset into it.
	   */
	- long
	- file2pc(char *file, ulong line)
	+ uvlong
	+ file2pc(char *file, long line)
	  {
	  	File *fp;
	- 	int i;
	- 	long pc;
	- 	ulong start, end;
	+ 	long i;
	+ 	uvlong pc, start, end;
	  	short *name;
	  
	  	if(buildtbls() == 0 || files == 0)
	- 		return -1;
	+ 		return ~0;
	  	name = encfname(file);
	  	if(name == 0) {			/* encode the file name */
	  		werrstr("file %s not found", file);
	- 		return -1;
	+ 		return ~0;
	  	} 
	  		/* find this history stack */
	  	for(i = 0, fp = files; i < nfiles; i++, fp++)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:823,829 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:846,852
	  	free(name);
	  	if(i >= nfiles) {
	  		werrstr("line %ld in file %s not found", line, file);
	- 		return -1;
	+ 		return ~0;
	  	}
	  	start = fp->addr;		/* first text addr this file */
	  	if(i < nfiles-1)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:835,848 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:858,872
	  	 * run the state machine to locate the pc closest to that value.
	  	 */
	  	if(debug)
	- 		print("find pc for %ld - between: %lux and %lux\n", line, start, end);
	+ 		print("find pc for %ld - between: %llux and %llux\n", line, start, end);
	  	pc = line2addr(line, start, end);
	- 	if(pc == -1) {
	+ 	if(pc == ~0) {
	  		werrstr("line %ld not in file %s", line, file);
	- 		return -1;
	+ 		return ~0;
	  	}
	  	return pc;
	  }
	+ 
	  /*
	   *	search for a path component index
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:856,861 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:880,886
	  			return i;
	  	return -1;
	  }
	+ 
	  /*
	   *	Encode a char file name as a sequence of short indices
	   *	into the file name dictionary.
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:893,904 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:918,930
	  	dest[i] = 0;
	  	return dest;
	  }
	+ 
	  /*
	   *	Search a history stack for a matching file name accumulating
	   *	the size of intervening files in the stack.
	   */
	  static int
	- hline(File *fp, short *name, ulong *line)
	+ hline(File *fp, short *name, long *line)
	  {
	  	Hist *hp;
	  	int offset, depth;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:942,947 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:968,974
	  	*line = ln+offset;
	  	return 1;
	  }
	+ 
	  /*
	   *	compare two encoded file names
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:966,979 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:993,1006
	  	}
	  	return *s == 0;
	  }
	+ 
	  /*
	   *	Convert a pc to a "file:line {file:line}" string.
	   */
	- int
	- fileline(char *str, int n, ulong dot)
	+ long
	+ fileline(char *str, int n, uvlong dot)
	  {
	- 	long line;
	- 	int top, bot, mid;
	+ 	long line, top, bot, mid;
	  	File *f;
	  
	  	*str = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1008,1014 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1035,1041
	  {
	  	Hist *start;			/* start of current level */
	  	Hist *h;			/* current entry */
	- 	int delta;			/* sum of size of files this level */
	+ 	long delta;			/* sum of size of files this level */
	  	int k;
	  
	  	start = base;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1067,1072 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1094,1100
	   ********************/
	  	return 0;
	  }
	+ 
	  /*
	   *	convert an encoded file name to a string.
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1093,1098 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1121,1127
	  	}
	  	return i;
	  }
	+ 
	  /*
	   *	compare the values of two symbol table entries.
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1106,1111 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1135,1141
	  		return i;
	  	return strcmp((*(Sym**)a)->name, (*(Sym**)b)->name);
	  }
	+ 
	  /*
	   *	compare the values of the symbols referenced by two text table entries
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1114,1119 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1144,1150
	  {
	  	return ((Txtsym*)a)->sym->value - ((Txtsym*)b)->sym->value;
	  }
	+ 
	  /*
	   *	compare the values of the symbols referenced by two file table entries
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1122,1127 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1153,1159
	  {
	  	return ((File*)a)->addr - ((File*)b)->addr;
	  }
	+ 
	  /*
	   *	fill an interface Symbol structure from a symbol table entry
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1160,1183 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1192,1214
	  	}
	  	s->handle = 0;
	  }
	+ 
	  /*
	   *	find the stack frame, given the pc
	   */
	- long
	- pc2sp(ulong pc)
	+ uvlong
	+ pc2sp(uvlong pc)
	  {
	- 	uchar *c;
	- 	uchar u;
	- 	ulong currpc;
	- 	long currsp;
	+ 	uchar *c, u;
	+ 	uvlong currpc, currsp;
	  
	  	if(spoff == 0)
	- 		return -1;
	+ 		return ~0;
	  	currsp = 0;
	  	currpc = txtstart - mach->pcquant;
	  
	  	if(pc<currpc || pc>txtend)
	- 		return -1;
	+ 		return ~0;
	  	for(c = spoff; c < spoffend; c++) {
	  		if (currpc >= pc)
	  			return currsp;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1194,1210 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1225,1241
	  			currpc += mach->pcquant*(u-129);
	  		currpc += mach->pcquant;
	  	}
	- 	return -1;
	+ 	return ~0;
	  }
	+ 
	  /*
	   *	find the source file line number for a given value of the pc
	   */
	  long
	- pc2line(ulong pc)
	+ pc2line(uvlong pc)
	  {
	- 	uchar *c;
	- 	uchar u;
	- 	ulong currpc;
	+ 	uchar *c, u;
	+ 	uvlong currpc;
	  	long currline;
	  
	  	if(pcline == 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1212,1218 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1243,1249
	  	currline = 0;
	  	currpc = txtstart-mach->pcquant;
	  	if(pc<currpc || pc>txtend)
	- 		return -1;
	+ 		return ~0;
	  
	  	for(c = pcline; c < pclineend; c++) {
	  		if(currpc >= pc)
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1230,1237 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1261,1269
	  			currpc += mach->pcquant*(u-129);
	  		currpc += mach->pcquant;
	  	}
	- 	return -1;
	+ 	return ~0;
	  }
	+ 
	  /*
	   *	find the pc associated with a line number
	   *	basepc and endpc are text addresses bounding the search.
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1239,1260 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1271,1291
	   *	usually, basepc and endpc contain the first text address in
	   *	a file and the first text address in the following file, respectively.
	   */
	- long
	- line2addr(ulong line, ulong basepc, ulong endpc)
	+ uvlong
	+ line2addr(long line, uvlong basepc, uvlong endpc)
	  {
	- 	uchar *c;
	- 	uchar u;
	- 	ulong currpc;
	+ 	uchar *c,  u;
	+ 	uvlong currpc, pc;
	  	long currline;
	  	long delta, d;
	- 	long pc, found;
	+ 	int found;
	  
	  	if(pcline == 0 || line == 0)
	- 		return -1;
	+ 		return ~0;
	  
	  	currline = 0;
	  	currpc = txtstart-mach->pcquant;
	- 	pc = -1;
	+ 	pc = ~0;
	  	found = 0;
	  	delta = HUGEINT;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/sym.c:1287,1294 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/sym.c:1318,1326
	  	}
	  	if(found)
	  		return pc;
	- 	return -1;
	+ 	return ~0;
	  }
	+ 
	  /*
	   *	Print a history stack (debug). if count is 0, prints the whole stack
	   */
 [rsc] --rw-rw-r-- M 451989 jmk sys 3436 Nov  6 10:02 sys/src/libmach/u.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/u.c:108,115 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/u.c:108,116
	  	"setSB",	/* static base register name */
	  	0,		/* value */
	  	0x2000,		/* page size */
	- 	0x80000000,	/* kernel base */
	+ 	0x80000000ULL,	/* kernel base */
	  	0,		/* kernel text mask */
	+ 	0x7FFFFFFFULL,	/* user stack top */
	  	4,		/* quantization of pc */
	  	4,		/* szaddr */
	  	4,		/* szreg */
 [rsc] --rw-rw-r-- M 451989 jmk sys 21910 Nov  6 10:03 sys/src/libmach/udb.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:8,17 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:8,17
	   */
	  
	  static	char	*sparc64excep(Map*, Rgetter);
	- static	int	sparc64foll(Map*, ulong, Rgetter, ulong*);
	- static	int	sparc64inst(Map*, ulong, char, char*, int);
	- static	int	sparc64das(Map*, ulong, char*, int);
	- static	int	sparc64instlen(Map*, ulong);
	+ static	int	sparc64foll(Map*, uvlong, Rgetter, uvlong*);
	+ static	int	sparc64inst(Map*, uvlong, char, char*, int);
	+ static	int	sparc64das(Map*, uvlong, char*, int);
	+ static	int	sparc64instlen(Map*, uvlong);
	  
	  Machdata sparc64mach =
	  {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:143,149 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:143,149
	  	int	target;		/* SETHI+ADD dest reg */
	  	long	w0;
	  	long	w1;
	- 	ulong	addr;		/* pc of instruction */
	+ 	uvlong	addr;		/* pc of instruction */
	  	char	*curr;		/* current fill level in output buffer */
	  	char	*end;		/* end of buffer */
	  	int 	size;		/* number of longs in instr */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:153,159 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:153,159
	  static	Map	*mymap;		/* disassembler context */
	  static	int	dascase;
	  
	- static int	mkinstr(ulong, Instr*);
	+ static int	mkinstr(uvlong, Instr*);
	  static void	bra1(Instr*, char*, char*[]);
	  static void	bra(Instr*, char*);
	  static void	fbra(Instr*, char*);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:317,323 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:317,323
	  static int
	  decode(ulong pc, Instr *i)
	  {
	- 	long w;
	+ 	ulong w;
	  
	  	if (get4(mymap, pc, &w) < 0) {
	  		werrstr("can't read instruction: %r");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:350,356 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:350,356
	  }
	  
	  static int
	- mkinstr(ulong pc, Instr *i)
	+ mkinstr(uvlong pc, Instr *i)
	  {
	  	Instr xi;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:381,387 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:381,387
	  }
	  
	  static int
	- printins(Map *map, ulong pc, char *buf, int n)
	+ printins(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr instr;
	  	void (*f)(Instr*, char*);
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:451,457 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:451,457
	  }
	  
	  static int
	- sparc64inst(Map *map, ulong pc, char modifier, char *buf, int n)
	+ sparc64inst(Map *map, uvlong pc, char modifier, char *buf, int n)
	  {
	  	static int fmtinstalled = 0;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:469,475 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:469,475
	  }
	  
	  static int
	- sparc64das(Map *map, ulong pc, char *buf, int n)
	+ sparc64das(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr instr;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:490,496 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:490,496
	  }
	  
	  static int
	- sparc64instlen(Map *map, ulong pc)
	+ sparc64instlen(Map *map, uvlong pc)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:527,533 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:527,533
	  address(Instr *i)
	  {
	  	Symbol s, s2;
	- 	long off, off1;
	+ 	uvlong off, off1;
	  
	  	if (i->rs1 == 1 && plocal(i) >= 0)
	  		return;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:537,543 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:537,543
	  			&& (s.class == CDATA || s.class == CTEXT)) {
	  		if(off==s.value && s.name[0]=='$'){
	  			off1 = 0;
	- 			get4(mymap, s.value, &off1);
	+ 			geta(mymap, s.value, &off1);
	  			if(off1 && findsym(off1, CANY, &s2) && s2.value == off1){
	  				bprint(i, "$%s(SB)", s2.name);
	  				return;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/udb.c:1034,1040 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/udb.c:1034,1040
	  }
	  
	  static int
	- sparc64foll(Map *map, ulong pc, Rgetter rget, ulong *foll)
	+ sparc64foll(Map *map, uvlong pc, Rgetter rget, uvlong *foll)
	  {
	  	ulong w, r1, r2;
	  	char buf[8];
 [rsc] --rw-rw-r-- M 451989 glenda sys 3446 Nov  6 10:02 sys/src/libmach/v.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/v.c:106,113 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/v.c:106,114
	  	"setR30",	/* static base register name */
	  	0,		/* value */
	  	0x1000,		/* page size */
	- 	0xC0000000,	/* kernel base */
	- 	0x40000000,	/* kernel text mask */
	+ 	0xC0000000ULL,	/* kernel base */
	+ 	0x40000000ULL,	/* kernel text mask */
	+ 	0x7FFFFFFFULL,	/* user stack top */
	  	4,		/* quantization of pc */
	  	4,		/* szaddr */
	  	4,		/* szreg */
 [rsc] --rw-rw-r-- M 451989 glenda sys 10258 Nov  6 10:03 sys/src/libmach/vcodas.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vcodas.c:6,12 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vcodas.c:6,12
	  	/* mips native disassembler */
	  
	  typedef struct {
	- 	long addr;			/* pc of instr */
	+ 	uvlong addr;			/* pc of instr */
	  	uchar op;			/* bits 31-26 */
	  	uchar rs;			/* bits 25-21 */
	  	uchar rt;			/* bits 20-16 */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vcodas.c:282,290 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vcodas.c:282,290
	  
	  
	  static int
	- mkinstr(Instr *i, Map *map, ulong pc)
	+ mkinstr(Instr *i, Map *map, uvlong pc)
	  {
	- 	long w;
	+ 	ulong w;
	  
	  	if (get4(map, pc, &w) < 0) {
	  		werrstr("can't read instruction: %r");
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vcodas.c:506,512 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vcodas.c:506,512
	  }
	  
	  int
	- _mipscoinst(Map *map, ulong pc, char *buf, int n)
	+ _mipscoinst(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr i;
	  	Opcode *o;
 [rsc] --rw-rw-r-- M 451989 glenda sys 22264 Nov  6 10:03 sys/src/libmach/vdb.c
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:7,16 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:7,16
	   */
	  
	  static	char	*mipsexcep(Map*, Rgetter);
	- static	int	mipsfoll(Map*, ulong, Rgetter, ulong*);
	- static	int	mipsinst(Map*, ulong, char, char*, int);
	- static	int	mipsdas(Map*, ulong, char*, int);
	- static	int	mipsinstlen(Map*, ulong);
	+ static	int	mipsfoll(Map*, uvlong, Rgetter, uvlong*);
	+ static	int	mipsinst(Map*, uvlong, char, char*, int);
	+ static	int	mipsdas(Map*, uvlong, char*, int);
	+ static	int	mipsinstlen(Map*, uvlong);
	  
	  /*
	   *	Debugger interface
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:123,129 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:123,129
	  static	char FRAMENAME[] = ".frame";
	  
	  typedef struct {
	- 	ulong addr;
	+ 	uvlong addr;
	  	uchar op;			/* bits 31-26 */
	  	uchar rs;			/* bits 25-21 */
	  	uchar rt;			/* bits 20-16 */
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:144,152 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:144,152
	  static Map *mymap;
	  
	  static int
	- decode(ulong pc, Instr *i)
	+ decode(uvlong pc, Instr *i)
	  {
	- 	long w;
	+ 	ulong w;
	  	extern Mach mmips2le;
	  
	  	if (get4(mymap, pc, &w) < 0) {
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:172,178 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:172,178
	  }
	  
	  static int
	- mkinstr(ulong pc, Instr *i)
	+ mkinstr(uvlong pc, Instr *i)
	  {
	  	Instr x;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:993,999 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:993,999
	  }
	  
	  static int
	- printins(Map *map, ulong pc, char *buf, int n)
	+ printins(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr i;
	  	Opcode *o;
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:1046,1056 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:1046,1056
	  	return i.size*4;
	  }
	  
	- extern	int	_mipscoinst(Map *, ulong, char*, int);
	+ extern	int	_mipscoinst(Map *, uvlong, char*, int);
	  
	  	/* modifier 'I' toggles the default disassembler type */
	  static int
	- mipsinst(Map *map, ulong pc, char modifier, char *buf, int n)
	+ mipsinst(Map *map, uvlong pc, char modifier, char *buf, int n)
	  {
	  	if ((asstype == AMIPSCO && modifier == 'i')
	  		|| (asstype == AMIPS && modifier == 'I'))
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:1060,1066 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:1060,1066
	  }
	  
	  static int
	- mipsdas(Map *map, ulong pc, char *buf, int n)
	+ mipsdas(Map *map, uvlong pc, char *buf, int n)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:1080,1086 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:1080,1086
	  }
	  
	  static int
	- mipsinstlen(Map *map, ulong pc)
	+ mipsinstlen(Map *map, uvlong pc)
	  {
	  	Instr i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/vdb.c:1091,1097 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/vdb.c:1091,1097
	  }
	  
	  static int
	- mipsfoll(Map *map, ulong pc, Rgetter rget, ulong *foll)
	+ mipsfoll(Map *map, uvlong pc, Rgetter rget, uvlong *foll)
	  {
	  	ulong w, l;
	  	char buf[8];
 [rsc] --rw-rw-r-- M 451989 glenda sys 2301 Nov  6 11:01 sys/src/libmach/elf.h
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/elf.h:1,22 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/elf.h:1,21
	- 
	  /*
	   *	Definitions needed for  accessing Irix ELF headers
	   */
	  typedef struct {
	- 	unsigned char	ident[16];	/* ident bytes */
	- 	ushort		type;		/* file type */
	- 	ushort		machine;	/* target machine */
	- 	int		version;	/* file version */
	- 	ulong		elfentry;	/* start address */
	- 	ulong		phoff;		/* phdr file offset */
	- 	ulong		shoff;		/* shdr file offset */
	- 	int		flags;		/* file flags */
	- 	ushort		ehsize;		/* sizeof ehdr */
	- 	ushort		phentsize;	/* sizeof phdr */
	- 	ushort		phnum;		/* number phdrs */
	- 	ushort		shentsize;	/* sizeof shdr */
	- 	ushort		shnum;		/* number shdrs */
	- 	ushort		shstrndx;	/* shdr string index */
	+ 	uchar	ident[16];	/* ident bytes */
	+ 	ushort	type;		/* file type */
	+ 	ushort	machine;	/* target machine */
	+ 	int	version;	/* file version */
	+ 	ulong	elfentry;	/* start address */
	+ 	ulong	phoff;		/* phdr file offset */
	+ 	ulong	shoff;		/* shdr file offset */
	+ 	int	flags;		/* file flags */
	+ 	ushort	ehsize;		/* sizeof ehdr */
	+ 	ushort	phentsize;	/* sizeof phdr */
	+ 	ushort	phnum;		/* number phdrs */
	+ 	ushort	shentsize;	/* sizeof shdr */
	+ 	ushort	shnum;		/* number shdrs */
	+ 	ushort	shstrndx;	/* shdr string index */
	  } Ehdr;
	  
	  typedef struct {
 [rsc] --rw-rw-r-- M 451989 glenda sys 604 Nov  6 11:01 sys/src/libmach/obj.h
	/n/sourcesdump/2005/1106/plan9/sys/src/libmach/obj.h:21,24 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/libmach/obj.h:21,24
	  };
	  
	  #define UNKNOWN	'?'
	- void		_offset(int, long);
	+ void		_offset(int, vlong);

64-bit fixes, also deal with PC stack moving.
 [rsc] --rw-rw-r-- M 451989 glenda sys 2363 Nov  6 10:04 sys/lib/acid/leak
	/n/sourcesdump/2005/1106/plan9/sys/lib/acid/leak:83,89 - 
	/n/sourcesdump/2005/1107/plan9/sys/lib/acid/leak:83,89
	  	print("range ", type, " ", s\X, " ", e\X, "\n");
	  	x = s;
	  	while x < e do {
	- 		y = *x;
	+ 		y = *(x\X);
	  		if isptr(y) then print("data ", x\X, " ", y\X, " ", type, "\n");
	  		x = x + 4;
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/lib/acid/leak:90,98 - 
	/n/sourcesdump/2005/1107/plan9/sys/lib/acid/leak:90,113
	  }
	  
	  defn
	+ stacktop()
	+ {
	+ 	local e, m;
	+ 	
	+ 	m = map();
	+ 	while m != {} do {
	+ 		e = head m;
	+ 		if e[0] == "*data" then
	+ 			return e[2];
	+ 		m = tail m;
	+ 	}
	+ 	return 0x7ffff000;
	+ }
	+ 			
	+ defn
	  dumpmem()
	  {
	- 	local s;
	+ 	local s, top;
	  
	  	xbloc = *bloc;
	  	// assume map()[1] is "data" 
	/n/sourcesdump/2005/1106/plan9/sys/lib/acid/leak:99,110 - 
	/n/sourcesdump/2005/1107/plan9/sys/lib/acid/leak:114,126
	  	dumprange(map()[1][1], end, "bss");	// bss
	  	dumprange(end, xbloc, "alloc");	// allocated
	  
	- 	if 0x7efff000 < *SP && *SP < 0x7ffff000 then 
	+ 	top = stacktop() - 8;
	+ 	if top-0x01000000 < *SP && *SP < top then
	  		s = *SP;
	  	else
	- 		s = 0x7fff7000;	// 32 k
	+ 		s = top-32*1024;
	  
	- 	dumprange(s, 0x7ffff000, "stack");
	+ 	dumprange(s, top, "stack");
	  }
	  
	  defn

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 4273 Nov  6 10:04 sys/src/cmd/acid/acid.h
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/acid.h:37,43 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/acid.h:37,42
	  Extern int	iop;
	  Extern char	symbol[Strsize];
	  Extern int	interactive;
	- Extern Node*	code;
	  Extern int	na;
	  Extern int	wtflag;
	  Extern Map*	cormap;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/acid.h:45,59 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/acid.h:44,55
	  Extern Lsym*	hash[Hashsize];
	  Extern long	dogc;
	  Extern Rplace*	ret;
	- Extern char*	filename;
	  Extern char*	aout;
	  Extern int	gotint;
	- Extern long	flen;
	  Extern Gc*	gcl;
	  Extern int	stacked;
	  Extern jmp_buf	err;
	  Extern Node*	prnt;
	- Extern Node*	fomt;
	  Extern List*	tracelist;
	  Extern int	initialising;
	  Extern int	quiet;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/acid.h:182,188 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/acid.h:178,184
	  void	catcher(void*, char*);
	  void	checkqid(int, int);
	  void	cmd(void);
	- Node*	con(int);
	+ Node*	con(vlong);
	  List*	construct(Node*);
	  void	ctrace(int);
	  void	decl(Node*);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/acid.h:194,211 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/acid.h:190,206
	  void	error(char*, ...);
	  void	execute(Node*);
	  void	fatal(char*, ...);
	- ulong	findframe(ulong);
	  void	flatten(Node**, Node*);
	  void	gc(void);
	  char*	getstatus(int);
	  void*	gmalloc(long);
	- void	indir(Map*, ulong, char, Node*);
	+ void	indir(Map*, uvlong, char, Node*);
	  void	installbuiltin(void);
	  void	kinit(void);
	  int	Lfmt(Fmt*);
	  int	listcmp(List*, List*);
	  int	listlen(List*);
	- List*	listvar(char*, long);
	+ List*	listvar(char*, vlong);
	  void	loadmodule(char*);
	  void	loadvars(void);
	  Lsym*	look(char*);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/acid.h:224,233 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/acid.h:219,227
	  void	pstr(String*);
	  void	pushfile(char*);
	  void	pushstr(Node*);
	- ulong	raddr(char*);
	  void	readtext(char*);
	  void	restartio(void);
	- vlong	rget(Map*, char*);
	+ uvlong	rget(Map*, char*);
	  String	*runenode(Rune*);
	  int	scmp(String*, String*);
	  void	sproc(int);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/acid.h:236,242 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/acid.h:230,236
	  String*	strnode(char*);
	  String*	strnodlen(char*, int);
	  char*	system(void);
	- void	trlist(Map*, ulong, ulong, Symbol*);
	+ void	trlist(Map*, uvlong, uvlong, Symbol*);
	  void	unwind(void);
	  void	userinit(void);
	  void	varreg(void);
 [rsc] --rw-rw-r-- M 451989 glenda sys 20193 Nov  6 10:04 sys/src/cmd/acid/builtin.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:343,349 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:343,349
	  {
	  	int n, i;
	  	Node res;
	- 	ulong f[10];
	+ 	uvlong f[10];
	  	List **tail, *l;
	  
	  	if(args == 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:370,376 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:370,376
	  {
	  	int n;
	  	Node res;
	- 	ulong bounds[2];
	+ 	uvlong bounds[2];
	  	List *l;
	  
	  	if(args == 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:425,438 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:425,438
	  
	  	c = *p;
	  	*p++ = '\0';
	- 	r->ival = file2pc(res.string->string, atoi(p));
	+ 	r->ival = file2pc(res.string->string, strtol(p, 0, 0));
	  	p[-1] = c;
	- 	if(r->ival == -1)
	+ 	if(r->ival == ~0)
	  		error("filepc(filename:line): can't find address");
	  
	  	r->op = OCONST;
	  	r->type = TINT;
	- 	r->fmt = 'D';
	+ 	r->fmt = 'V';
	  }
	  
	  void
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:674,681 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:674,681
	  
	  	r->op = OCONST;
	  	r->type = TINT;
	- 	r->ival = strtoul(res.string->string, 0, 0);
	- 	r->fmt = 'D';
	+ 	r->ival = strtoull(res.string->string, 0, 0);
	+ 	r->fmt = 'V';
	  }
	  
	  void
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:683,689 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:683,689
	  {
	  	Node res;
	  	Node *av[Maxarg];
	- 	int ival;
	+ 	vlong ival;
	  	char buf[128], *fmt;
	  
	  	if(args == 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:696,703 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:696,703
	  	expr(av[0], &res);
	  	if(res.type != TINT)
	  		error("itoa(integer): arg type");
	- 	ival = (int)res.ival;
	- 	fmt = "%d";
	+ 	ival = res.ival;
	+ 	fmt = "%lld";
	  	if(na == 2){
	  		expr(av[1], &res);
	  		if(res.type != TSTRING)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:705,711 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:705,711
	  		fmt = res.string->string;
	  	}
	  
	- 	sprint(buf, fmt, ival);
	+ 	snprint(buf, sizeof(buf), fmt, ival);
	  	r->op = OCONST;
	  	r->type = TSTRING;
	  	r->string = strnode(buf);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:733,747 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:733,747
	  		l->next = al(TINT);
	  		l = l->next;
	  		l->ival = m->seg[i].b;
	- 		l->fmt = 'X';
	+ 		l->fmt = 'W';
	  		l->next = al(TINT);
	  		l = l->next;
	  		l->ival = m->seg[i].e;
	- 		l->fmt = 'X';
	+ 		l->fmt = 'W';
	  		l->next = al(TINT);
	  		l = l->next;
	  		l->ival = m->seg[i].f;
	- 		l->fmt = 'X';
	+ 		l->fmt = 'W';
	  	}
	  	return h;
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:831,837 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:831,837
	  strace(Node *r, Node *args)
	  {
	  	Node *av[Maxarg], *n, res;
	- 	ulong pc, sp;
	+ 	uvlong pc, sp;
	  
	  	na = 0;
	  	flatten(av, args);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:857,863 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:857,863
	  
	  	tracelist = 0;
	  	if ((*machdata->ctrace)(cormap, pc, sp, res.ival, trlist) <= 0)
	- 		error("no stack frame");
	+ 		error("no stack frame: %r");
	  	r->type = TLIST;
	  	r->l = tracelist;
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:896,902 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:896,902
	  	free(rp);
	  }
	  
	- char vfmt[] = "aBbcCdDfFgGiIoOqQrRsSuUVxXYZ";
	+ char vfmt[] = "aBbcCdDfFgGiIoOqQrRsSuUVWxXYZ";
	  
	  void
	  fmt(Node *r, Node *args)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:954,962 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:954,959
	  	case 'x':
	  		Bprint(bout, "%.4lux", (ulong)res->ival&0xffff);
	  		break;
	- 	case 'W':
	- 		Bprint(bout, "%.16llux", res->ival);
	- 		break;
	  	case 'D':
	  		Bprint(bout, "%d", (int)res->ival);
	  		break;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:975,980 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:972,980
	  	case 'V':
	  		Bprint(bout, "%lld", res->ival);
	  		break;
	+ 	case 'W':
	+ 		Bprint(bout, "%.8llux", res->ival);
	+ 		break;
	  	case 'Y':
	  		Bprint(bout, "%.16llux", res->ival);
	  		break;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/builtin.c:1214,1218 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/builtin.c:1214,1218
	  	p = strrchr(buf, ':');
	  	if(p == 0)
	  		error("pcline(addr): funny file %s", buf);
	- 	r->ival = atoi(p+1);	
	+ 	r->ival = strtol(p+1, 0, 0);	
	  }
 [rsc] --rw-rw-r-- M 451989 glenda sys 5568 Nov  6 10:04 sys/src/cmd/acid/dbg.y
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/dbg.y:11,17 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/dbg.y:11,17
	  {
	  	Node	*node;
	  	Lsym	*sym;
	- 	ulong	ival;
	+ 	uvlong	ival;
	  	float	fval;
	  	String	*string;
	  }
 [rsc] --rw-rw-r-- M 451989 glenda sys 2162 Nov  6 10:04 sys/src/cmd/acid/dot.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/dot.c:28,34 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/dot.c:28,34
	  	char *s;
	  	Type *t;
	  	Node res;
	- 	ulong addr;
	+ 	uvlong addr;
	  
	  	s = n->sym->name;
	  	if(s == 0)
 [rsc] --rw-rw-r-- M 451989 glenda sys 8383 Nov  6 10:04 sys/src/cmd/acid/exec.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/exec.c:62,68 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/exec.c:62,68
	  	Value *v;
	  	Lsym *sl;
	  	Node *l, *r;
	- 	int i, s, e;
	+ 	vlong i, s, e;
	  	Node res, xx;
	  	static int stmnt;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/exec.c:203,213 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/exec.c:203,213
	  }
	  
	  void
	- indir(Map *m, ulong addr, char fmt, Node *r)
	+ indir(Map *m, uvlong addr, char fmt, Node *r)
	  {
	  	int i;
	- 	long ival;
	- 	vlong vval;
	+ 	ulong lval;
	+ 	uvlong uvval;
	  	int ret;
	  	uchar cval;
	  	ushort sval;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/exec.c:241,246 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/exec.c:241,252
	  		break;
	  	case 'a':
	  	case 'A':
	+ 		r->type = TINT;
	+ 		ret = geta(m, addr, &uvval);
	+ 		if (ret < 0)
	+ 			error("indir: %r");
	+ 		r->ival = uvval;
	+ 		break;
	  	case 'B':
	  	case 'X':
	  	case 'D':
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/exec.c:248,257 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/exec.c:254,263
	  	case 'O':
	  	case 'Q':
	  		r->type = TINT;
	- 		ret = get4(m, addr, &ival);
	+ 		ret = get4(m, addr, &lval);
	  		if (ret < 0)
	  			error("indir: %r");
	- 		r->ival = ival;
	+ 		r->ival = lval;
	  		break;
	  	case 'V':
	  	case 'W':
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/exec.c:258,267 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/exec.c:264,273
	  	case 'Y':
	  	case 'Z':
	  		r->type = TINT;
	- 		ret = get8(m, addr, &vval);
	+ 		ret = get8(m, addr, &uvval);
	  		if (ret < 0)
	  			error("indir: %r");
	- 		r->ival = vval;
	+ 		r->ival = uvval;
	  		break;
	  	case 's':
	  		r->type = TSTRING;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/exec.c:354,359 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/exec.c:360,366
	  {
	  	uchar cval;
	  	ushort sval;
	+ 	long lval;
	  	Node res, aes;
	  	int ret;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/exec.c:393,404 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/exec.c:400,414
	  		break;
	  	case 'a':
	  	case 'A':
	+ 		ret = puta(m, aes.ival, res.ival);
	+ 		break;
	  	case 'B':
	  	case 'X':
	  	case 'D':
	  	case 'U':
	  	case 'O':
	- 		ret = put4(m, aes.ival, res.ival);
	+ 		lval = res.ival;
	+ 		ret = put4(m, aes.ival, lval);
	  		break;
	  	case 'V':
	  	case 'W':
 [rsc] --rw-rw-r-- M 451989 glenda sys 15220 Nov  6 10:04 sys/src/cmd/acid/expr.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/expr.c:135,141 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/expr.c:135,141
	  {
	  	char *p;
	  	Node *lp;
	- 	long ival;
	+ 	uvlong ival;
	  	Frtype *f;
	  
	  	p = n->sym->name;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/expr.c:553,559 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/expr.c:553,559
	  	res->type = TINT;
	  	if(l.type != TINT || r.type != TINT)
	  		error("bad expr type >>");
	- 	res->ival = (unsigned)l.ival>>r.ival;
	+ 	res->ival = (uvlong)l.ival>>r.ival;
	  }
	  
	  void
 [rsc] --rw-rw-r-- M 451989 glenda sys 7963 Nov  6 10:04 sys/src/cmd/acid/lex.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/lex.c:168,182 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/lex.c:168,182
	  
	  	e = lexio;
	  	if(e) {
	- 		i = sprint(buf, "%s:%d", e->name, line);
	+ 		i = snprint(buf, sizeof(buf), "%s:%d", e->name, line);
	  		while(e->prev) {
	  			e = e->prev;
	  			if(initialising && e->prev == 0)
	  				break;
	- 			i += sprint(buf+i, " [%s:%d]", e->name, e->line);
	+ 			i += snprint(buf+i, sizeof(buf)-i, " [%s:%d]", e->name, e->line);
	  		}
	  	} else
	- 		sprint(buf, "no file:0");
	+ 		snprint(buf, sizeof(buf),  "no file:0");
	  	fmtstrcpy(f, buf);
	  	return 0;
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/lex.c:228,233 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/lex.c:228,235
	  				unlexc(c);
	  				break;
	  			}
	+ 			if(n >= Strsize)
	+ 				error("string escape too long");
	  			buf[n++] = c;
	  		}
	  		buf[n] = '\0';
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/lex.c:517,525 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/lex.c:519,527
	  		}
	  
	  		if(isbin)
	- 			yylval.ival = strtoul(symbol+2, 0, 2);
	+ 			yylval.ival = strtoull(symbol+2, 0, 2);
	  		else
	- 			yylval.ival = strtoul(symbol, 0, 0);
	+ 			yylval.ival = strtoull(symbol, 0, 0);
	  		return Tconst;
	  	}
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/lex.c:550,556 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/lex.c:552,558
	  enter(char *name, int t)
	  {
	  	Lsym *s;
	- 	ulong h;
	+ 	uint h;
	  	char *p;
	  	Value *v;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/lex.c:581,587 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/lex.c:583,589
	  look(char *name)
	  {
	  	Lsym *s;
	- 	ulong h;
	+ 	uint h;
	  	char *p;
	  
	  	h = 0;
 [rsc] --rw-rw-r-- M 451989 glenda sys 3680 Nov  6 10:04 sys/src/cmd/acid/list.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/list.c:173,179 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/list.c:173,179
	  }
	  
	  List*
	- listvar(char *s, long v)
	+ listvar(char *s, vlong v)
	  {
	  	List *l, *tl;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/list.c:192,201 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/list.c:192,201
	  }
	  
	  static List*
	- listlocals(Map *map, Symbol *fn, ulong fp)
	+ listlocals(Map *map, Symbol *fn, uvlong fp)
	  {
	  	int i;
	- 	long val;
	+ 	uvlong val;
	  	Symbol s;
	  	List **tail, *l2;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/list.c:209,215 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/list.c:209,215
	  		if(s.name[0] == '.')
	  			continue;
	  
	- 		if(get4(map, fp-s.value, &val) > 0) {
	+ 		if(geta(map, fp-s.value, &val) > 0) {
	  			*tail = listvar(s.name, val);
	  			tail = &(*tail)->next;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/list.c:218,228 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/list.c:218,228
	  }
	  
	  static List*
	- listparams(Map *map, Symbol *fn, ulong fp)
	+ listparams(Map *map, Symbol *fn, uvlong fp)
	  {
	  	int i;
	  	Symbol s;
	- 	long v;
	+ 	uvlong v;
	  	List **tail, *l2;
	  
	  	l2 = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/list.c:233,239 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/list.c:233,239
	  		if (s.class != CPARAM)
	  			continue;
	  
	- 		if(get4(map, fp+s.value, &v) > 0) {
	+ 		if(geta(map, fp+s.value, &v) > 0) {
	  			*tail = listvar(s.name, v);
	  			tail = &(*tail)->next;
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/list.c:242,248 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/list.c:242,248
	  }
	  
	  void
	- trlist(Map *map, ulong pc, ulong sp, Symbol *sym)
	+ trlist(Map *map, uvlong pc, uvlong sp, Symbol *sym)
	  {
	  	List *q, *l;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/list.c:265,271 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/list.c:265,271
	  	l->next = al(TINT);		/* called from address */
	  	l = l->next;
	  	l->ival = pc;
	- 	l->fmt = 'X';
	+ 	l->fmt = 'Y';
	  
	  	l->next = al(TLIST);		/* make list of params */
	  	l = l->next;
 [rsc] --rw-rw-r-- M 451989 glenda sys 8565 Nov  6 10:04 sys/src/cmd/acid/main.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:31,37 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:31,37
	  {
	  	Lsym *l;
	  	Node *n;
	- 	char buf[128], *s;
	+ 	char *s;
	  	int pid, i;
	  
	  	argv0 = argv[0];
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:73,80 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:73,80
	  			aout = argv[0];
	  		else
	  		if(isnumeric(argv[0])) {
	- 			pid = atoi(argv[0]);
	- 			sprint(prog, "/proc/%d/text", pid);
	+ 			pid = strtol(argv[0], 0, 0);
	+ 			snprint(prog, sizeof(prog), "/proc/%d/text", pid);
	  			aout = prog;
	  			if(argc > 1)
	  				aout = argv[1];
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:90,96 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:90,96
	  		}
	  	} else
	  	if(remote)
	- 		aout = "/mips/bcarrera";
	+ 		aout = "/mips/9ch";
	  
	  	fmtinstall('x', xfmt);
	  	fmtinstall('L', Lfmt);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:114,121 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:114,122
	  		if(access(lm[i], AREAD) >= 0)
	  			loadmodule(lm[i]);
	  		else {
	- 			sprint(buf, "/sys/lib/acid/%s", lm[i]);
	- 			loadmodule(buf);
	+ 			s = smprint("/sys/lib/acid/%s", lm[i]);
	+ 			loadmodule(s);
	+ 			free(s);
	  		}
	  	}
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:198,212 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:199,215
	  {
	  	Lsym *l;
	  	Node *n;
	- 	char buf[128], *p;
	+ 	char *buf, *p;
	  
	- 	sprint(buf, "/sys/lib/acid/%s", mach->name);
	+ 	buf = smprint("/sys/lib/acid/%s", mach->name);
	  	loadmodule(buf);
	+ 	free(buf);
	  	p = getenv("home");
	  	if(p != 0) {
	- 		sprint(buf, "%s/lib/acid", p);
	+ 		buf = smprint("%s/lib/acid", p);
	  		silent = 1;
	  		loadmodule(buf);
	+ 		free(buf);
	  	}
	  
	  	interactive = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:244,250 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:247,253
	  	Dir *d;
	  	Lsym *l;
	  	Value *v;
	- 	ulong length;
	+ 	uvlong length;
	  	Symbol sym;
	  	extern Machdata mipsmach;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:335,347 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:338,350
	  }
	  
	  Node*
	- con(int v)
	+ con(vlong v)
	  {
	  	Node *n;
	  
	  	n = an(OCONST, ZN, ZN);
	  	n->ival = v;
	- 	n->fmt = 'X';
	+ 	n->fmt = 'W';
	  	n->type = TINT;
	  	return n;
	  }
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:501,507 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:504,510
	  		return;
	  	}
	  
	- 	sprint(buf, "/proc/%d/text", pid);
	+ 	snprint(buf, sizeof(buf), "/proc/%d/text", pid);
	  	fd = open(buf, OREAD);
	  	if(fd < 0 || (d2 = dirfstat(fd)) == nil){
	  		print("checkqid: (qid not checked) dirstat %s: %r\n", buf);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:538,544 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:541,547
	  system(void)
	  {
	  	char *cpu, *p, *q;
	- 	static char kernel[128];
	+ 	static char *kernel;
	  
	  	cpu = getenv("cputype");
	  	if(cpu == 0) {
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:547,553 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:550,556
	  	}
	  	p = getenv("terminal");
	  	if(p == 0 || (p=strchr(p, ' ')) == 0 || p[1] == ' ' || p[1] == 0) {
	- 		p = "9power";
	+ 		p = "ch";
	  		print("missing or bad $terminal; assuming %s\n", p);
	  	}
	  	else{
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/main.c:555,562 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/main.c:558,569
	  		q = strchr(p, ' ');
	  		if(q)
	  			*q = 0;
	- 		sprint(kernel, "/%s/9%s", cpu, p);
	  	}
	+ 
	+ 	if(kernel != nil)
	+ 		free(kernel);
	+ 	kernel = smprint("/%s/9%s", cpu, p);
	+ 
	  	return kernel;
	  }
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 6831 Nov  6 10:04 sys/src/cmd/acid/print.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/print.c:109,116 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/print.c:109,115
	  		if(t == TINT || t == TFLOAT)
	  			Bprint(bout, " format %c", l->v->fmt);
	  		if(l->v->comt)
	- 			Bprint(bout, " complex %s",
	- 						l->v->comt->base->name);
	+ 			Bprint(bout, " complex %s", l->v->comt->base->name);
	  		Bputc(bout, '\n');
	  		def = 1;
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/print.c:252,258 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/print.c:251,257
	  	case OCONST:
	  		switch(n->type) {
	  		case TINT:
	- 			Bprint(bout, "%d", (int)n->ival);
	+ 			Bprint(bout, "%lld", n->ival);
	  			break;
	  		case TFLOAT:
	  			Bprint(bout, "%g", n->fval);
 [rsc] --rw-rw-r-- M 451989 glenda sys 4356 Nov  6 10:04 sys/src/cmd/acid/proc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/proc.c:29,41 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/proc.c:29,40
	  {
	  	Lsym *s;
	  	char buf[64];
	- 	ulong proctab;
	- 	int fd, i, fcor;
	+ 	int i, fcor;
	  
	  	if(symmap == 0)
	  		error("no map");
	  
	- 	sprint(buf, "/proc/%d/mem", pid);
	+ 	snprint(buf, sizeof(buf), "/proc/%d/mem", pid);
	  	fcor = open(buf, ORDWR);
	  	if(fcor < 0)
	  		error("setproc: open %s: %r", buf);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/proc.c:42,64 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/proc.c:41,46
	  
	  	checkqid(symmap->seg[0].fd, pid);
	  
	- 	if(kernel) {
	- 		proctab = 0;
	- 		sprint(buf, "/proc/%d/proc", pid);
	- 		fd = open(buf, OREAD);
	- 		if(fd >= 0) {
	- 			i = read(fd, buf, sizeof(buf));
	- 			if(i >= 0) {
	- 				buf[i] = '\0';
	- 				proctab = strtoul(buf, 0, 0);
	- 			}
	- 			close(fd);
	- 		}
	- 		s = look("proc");
	- 		if(s != 0)
	- 			s->v->ival = proctab;
	- 	}
	- 
	  	s = look("pid");
	  	s->v->ival = pid;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/proc.c:88,94 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/proc.c:70,76
	  	case 0:
	  		rfork(RFNAMEG|RFNOTEG);
	  
	- 		sprint(buf, "/proc/%d/ctl", getpid());
	+ 		snprint(buf, sizeof(buf), "/proc/%d/ctl", getpid());
	  		fd = open(buf, ORDWR);
	  		if(fd < 0)
	  			fatal("new: open %s: %r", buf);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/proc.c:132,138 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/proc.c:114,120
	  		return;
	  	v = s->v;
	  
	- 	sprint(buf, "/proc/%d/note", pid);
	+ 	snprint(buf, sizeof(buf), "/proc/%d/note", pid);
	  	fd = open(buf, OREAD);
	  	if(fd < 0)
	  		error("pid=%d: open note: %r", pid);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/proc.c:193,199 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/proc.c:175,181
	  	if(new == -1)
	  		error("no free process slots");
	  
	- 	sprint(buf, "/proc/%d/ctl", pid);
	+ 	snprint(buf, sizeof(buf), "/proc/%d/ctl", pid);
	  	fd = open(buf, OWRITE);
	  	if(fd < 0)
	  		error("pid=%d: open ctl: %r", pid);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/proc.c:265,271 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/proc.c:247,253
	  	char *argv[16], buf[64];
	  	static char status[128];
	  
	- 	sprint(buf, "/proc/%d/status", pid);
	+ 	snprint(buf, sizeof(buf), "/proc/%d/status", pid);
	  	fd = open(buf, OREAD);
	  	if(fd < 0)
	  		error("open %s: %r", buf);
 [rsc] --rw-rw-r-- M 451989 glenda sys 4609 Nov  6 10:04 sys/src/cmd/acid/util.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/util.c:36,42 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/util.c:36,42
	  		}
	  	}
	  	if(renamed && !quiet)
	- 		print("\t%s=%s %c/%lux\n", s->name, buf, s->type, s->value);
	+ 		print("\t%s=%s %c/%llux\n", s->name, buf, s->type, s->value);
	  	if(l == 0)
	  		l = enter(buf, Tid);
	  	return l;	
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/util.c:49,55 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/util.c:49,55
	  	Sym *s;
	  	long n;
	  	Lsym *l;
	- 	ulong v;
	+ 	uvlong v;
	  	char buf[1024];
	  	List *list, **tail, *l2, *tl;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/util.c:178,189 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/util.c:178,189
	  	l->v->type = TLIST;
	  }
	  
	- vlong
	+ uvlong
	  rget(Map *map, char *reg)
	  {
	  	Lsym *s;
	- 	long x;
	- 	vlong v;
	+ 	ulong x;
	+ 	uvlong v;
	  	int ret;
	  
	  	s = look(reg);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/acid/util.c:191,199 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/acid/util.c:191,199
	  		fatal("rget: %s\n", reg);
	  
	  	if(s->v->fmt == 'W')
	- 		ret = get8(map, (long)s->v->ival, &v);
	+ 		ret = get8(map, s->v->ival, &v);
	  	else {
	- 		ret = get4(map, (long)s->v->ival, &x);
	+ 		ret = get4(map, s->v->ival, &x);
	  		v = x;
	  	}
	  	if(ret < 0)

Add -p flag to avoid setting memory private.
 [rsc] --rw-rw-r-- M 451989 glenda sys 10524 Nov  6 10:09 sys/src/cmd/auth/factotum/fs.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/auth/factotum/fs.c:3,8 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/auth/factotum/fs.c:3,9
	  int		askforkeys = 1;
	  char		*authaddr;
	  int		debug;
	+ int		doprivate = 1;
	  int		gflag;
	  char		*owner;
	  int		kflag;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/auth/factotum/fs.c:75,80 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/auth/factotum/fs.c:76,82
	  		break;
	  	case 'd':
	  		debug = 1;
	+ 		doprivate = 0;
	  		break;
	  	case 'g':		/* get: prompt for key for name and domain */
	  		gflag = 1;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/auth/factotum/fs.c:88,93 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/auth/factotum/fs.c:90,98
	  	case 'n':
	  		trysecstore = 0;
	  		break;
	+ 	case 'p':
	+ 		doprivate = 0;
	+ 		break;
	  	case 's':		/* set service name */
	  		service = EARGF(usage());
	  		break;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/auth/factotum/fs.c:100,106 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/auth/factotum/fs.c:105,111
	  
	  	if(argc != 0 && !gflag)
	  		usage();
	- 	if(!debug)
	+ 	if(doprivate)
	  		private();
	  
	  	initcap();
 [rsc] --rw-rw-r-- M 451989 glenda sys 18035 Nov  6 10:09 sys/src/cmd/auth/factotum/util.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/auth/factotum/util.c:348,353 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/auth/factotum/util.c:348,355
	  	if(p && findproto(p) == nil){
	  		werrstr("unknown protocol %s", p);
	  		_freeattr(attr1);
	+ 		_freeattr(attr2);
	+ 		_freeattr(attr3);
	  		return failure(ki->fss, nil);
	  	}
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/auth/factotum/util.c:374,379 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/auth/factotum/util.c:376,383
	  				}
	  			}
	  			_freeattr(attr1);
	+ 			_freeattr(attr2);
	+ 			_freeattr(attr3);
	  			k->ref++;
	  			*ret = k;
	  			return RpcOk;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/auth/factotum/util.c:381,386 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/auth/factotum/util.c:385,392
	  	}
	  	flog("%d: no key matches %A %A %A %A", ki->fss->seqnum, attr0, attr1, attr2, attr3);
	  	werrstr("no key matches %A %A", attr0, attr1);
	+ 	_freeattr(attr2);
	+ 	_freeattr(attr3);
	  	s = RpcFailure;
	  	if(askforkeys && who==nil && (hasqueries(attr0) || hasqueries(attr1))){
	  		if(nmatch == 0){

64-bit fixes, also fix handling of times in archives.
 [rsc] --rw-rw-r-- M 451989 glenda sys 826 Nov  6 10:05 sys/src/cmd/mk/arc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/arc.c:41,47 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/arc.c:41,47
	  
	  	sym = symlook("NREP", S_VAR, 0);
	  	if(sym){
	- 		w = (Word *) sym->value;
	+ 		w = sym->u.ptr;
	  		if (w && w->s && *w->s)
	  			nreps = atoi(w->s);
	  	}
 [rsc] --rw-rw-r-- M 451989 glenda sys 3071 Nov  6 10:05 sys/src/cmd/mk/archive.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/archive.c:18,38 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/archive.c:18,38
	  	t = mtime(archive);
	  	sym = symlook(archive, S_AGG, 0);
	  	if(sym){
	- 		if(force || (t > (long)sym->value)){
	+ 		if(force || t > sym->u.value){
	  			atimes(archive);
	- 			sym->value = (void *)t;
	+ 			sym->u.value = t;
	  		}
	  	}
	  	else{
	  		atimes(archive);
	  		/* mark the aggegate as having been done */
	- 		symlook(strdup(archive), S_AGG, "")->value = (void *)t;
	+ 		symlook(strdup(archive), S_AGG, "")->u.value = t;
	  	}
	  		/* truncate long member name to sizeof of name field in archive header */
	  	snprint(buf, sizeof(buf), "%s(%.*s)", archive, utfnlen(member, SARNAME), member);
	  	sym = symlook(buf, S_TIME, 0);
	  	if (sym)
	- 		return (long)sym->value;	/* uggh */
	+ 		return sym->u.value;
	  	return 0;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/archive.c:82,91 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/archive.c:82,92
	  atimes(char *ar)
	  {
	  	struct ar_hdr h;
	- 	long t;
	+ 	long at, t;
	  	int fd, i;
	  	char buf[BIGBLOCK];
	- 
	+ 	Dir *d;
	+ 	
	  	fd = open(ar, OREAD);
	  	if(fd < 0)
	  		return;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/archive.c:94,102 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/archive.c:95,111
	  		close(fd);
	  		return;
	  	}
	+ 	if((d = dirfstat(fd)) == nil){
	+ 		close(fd);
	+ 		return;
	+ 	}
	+ 	at = d->mtime;
	+ 	free(d);
	  	while(read(fd, (char *)&h, sizeof(h)) == sizeof(h)){
	  		t = atol(h.date);
	- 		if(t == 0)	/* as it sometimes happens; thanks ken */
	+ 		if(t >= at)	/* new things in old archives confuses mk */
	+ 			t = at-1;
	+ 		if(t <= 0)	/* as it sometimes happens; thanks ken */
	  			t = 1;
	  		for(i = sizeof(h.name)-1; i > 0 && h.name[i] == ' '; i--)
	  				;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/archive.c:104,110 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/archive.c:113,119
	  			i--;
	  		h.name[i+1]=0;		/* can stomp on date field */
	  		sprint(buf, "%s(%s)", ar, h.name);
	- 		symlook(strdup(buf), S_TIME, (void *)t)->value = (void *)t;
	+ 		symlook(strdup(buf), S_TIME, (void*)t)->u.value = t;
	  		t = atol(h.size);
	  		if(t&01) t++;
	  		LSEEK(fd, t, 1);
 [rsc] --rw-rw-r-- M 451989 glenda sys 2281 Nov  6 10:05 sys/src/cmd/mk/env.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/env.c:79,85 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/env.c:79,85
	  	for(p = myenv; *p; p++)
	  		if(strcmp(*p, s->name) == 0)
	  			return;
	- 	envinsert(s->name, (Word *) s->value);
	+ 	envinsert(s->name, s->u.ptr);
	  }
	  
	  void
 [rsc] --rw-rw-r-- M 451989 glenda sys 1299 Nov  6 10:05 sys/src/cmd/mk/file.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/file.c:22,28 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/file.c:22,28
	  
	  	sym = symlook(name, S_TIME, 0);
	  	if (sym)
	- 		return (long) sym->value;		/* uggh */
	+ 		return sym->u.value;		/* uggh */
	  
	  	t = mkmtime(name, 0);
	  	if(t == 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/file.c:76,82 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/file.c:76,82
	  		} while(*s);
	  		c = *s;
	  		*s = 0;
	- 		symlook(strdup(cp), S_TIME, (void *)t)->value = (void *)t;
	+ 		symlook(strdup(cp), S_TIME, (void *)t)->u.value = t;
	  		if (c)
	  			*s++ = c;
	  		while(*s){
 [rsc] --rw-rw-r-- M 451989 glenda sys 5822 Nov  6 10:05 sys/src/cmd/mk/graph.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/graph.c:40,46 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/graph.c:40,46
	  /*	print("applyrules(%lux='%s')\n", target, target);/**/
	  	sym = symlook(target, S_NODE, 0);
	  	if(sym)
	- 		return (Node *)(sym->value);
	+ 		return sym->u.ptr;
	  	target = strdup(target);
	  	node = newnode(target);
	  	head.n = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/graph.c:47,53 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/graph.c:47,53
	  	head.next = 0;
	  	sym = symlook(target, S_TARGET, 0);
	  	memset((char*)rmatch, 0, sizeof(rmatch));
	- 	for(r = sym? (Rule *)(sym->value):0; r; r = r->chain){
	+ 	for(r = sym? sym->u.ptr:0; r; r = r->chain){
	  		if(r->attr&META) continue;
	  		if(strcmp(target, r->target)) continue;
	  		if((!r->recipe || !*r->recipe) && (!r->tail || !r->tail->s || !*r->tail->s)) continue;	/* no effect; ignore */
 [rsc] --rw-rw-r-- M 451989 glenda sys 5330 Nov  6 10:05 sys/src/cmd/mk/mk.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/mk.c:217,227 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/mk.c:217,227
	  				str = strdup(buf);
	  			ret = pcmp(arc->prog, node->name, arc->n->name);
	  			if(sym)
	- 				sym->value = (void *)ret;
	+ 				sym->u.value = ret;
	  			else
	  				symlook(str, S_OUTOFDATE, (void *)ret);
	  		} else
	- 			ret = (int)(uintptr)sym->value;
	+ 			ret = sym->u.value;
	  		return(ret-1);
	  	} else if(strchr(arc->n->name, '(') && arc->n->time == 0)  /* missing archive member */
	  		return 1;
 [rsc] --rw-rw-r-- M 451989 glenda sys 3765 Nov  6 10:05 sys/src/cmd/mk/mk.h
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/mk.h:116,122 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/mk.h:116,125
	  {
	  	short		space;
	  	char		*name;
	- 	void		*value;
	+ 	union{
	+ 		void		*ptr;
	+ 		uintptr	value;
	+ 	} u;
	  	struct Symtab	*next;
	  } Symtab;
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 6941 Nov  6 10:05 sys/src/cmd/mk/plan9.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/plan9.c:49,55 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/plan9.c:49,55
	  			free(p);
	  			p = strdup(e[i].name);
	  			setvar(p, (void *) w);
	- 			symlook(p, S_EXPORTED, (void*)"")->value = (void*)"";
	+ 			symlook(p, S_EXPORTED, (void*)"")->u.ptr = "";
	  		}
	  		free(e);
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/plan9.c:346,352 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/plan9.c:346,351
	  dirtime(char *dir, char *path)
	  {
	  	int i, fd, n;
	- 	void *t;
	  	Dir *d;
	  	char buf[4096];
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/plan9.c:354,366 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/plan9.c:353,364
	  	if(fd >= 0){
	  		while((n = dirread(fd, &d)) > 0){
	  			for(i=0; i<n; i++){
	- 				t = (void*)d[i].mtime;
	- 				if(t == nil)
	+ 				if(d[i].mtime == 0)	/* yeah, this is likely */
	  					continue;
	  				sprint(buf, "%s%s", path, d[i].name);
	  				if(symlook(buf, S_TIME, 0))
	  					continue;
	- 				symlook(strdup(buf), S_TIME, t)->value = t;
	+ 				symlook(strdup(buf), S_TIME, (void*)d[i].mtime)->u.value = d[i].mtime;
	  			}
	  			free(d);
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/plan9.c:423,429 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/plan9.c:421,427
	  	if(!force){
	  		sym = symlook(name, S_TIME, 0);
	  		if(sym)
	- 			return (ulong)sym->value;
	+ 			return sym->u.value;
	  		return 0;
	  	}
	  	if((d = dirstat(name)) == nil)
 [rsc] --rw-rw-r-- M 451989 glenda sys 2543 Nov  6 10:05 sys/src/cmd/mk/recipe.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/recipe.c:63,69 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/recipe.c:63,69
	  			aw = aw->next;
	  			if((s = symlook(buf, S_NODE, 0)) == 0)
	  				continue;	/* not a node we are interested in */
	- 			n = (Node *)s->value;
	+ 			n = s->u.ptr;
	  			if(aflag == 0 && n->time) {
	  				for(a = n->prereqs; a; a = a->next)
	  					if(a->n && outofdate(n, a, 0))
 [rsc] --rw-rw-r-- M 451989 glenda sys 1946 Nov  6 10:05 sys/src/cmd/mk/rule.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/rule.c:15,21 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/rule.c:15,21
	  	r = 0;
	  	reuse = 0;
	  	if(sym = symlook(head, S_TARGET, 0)){
	- 		for(r = (Rule *)sym->value; r; r = r->chain)
	+ 		for(r = sym->u.ptr; r; r = r->chain)
	  			if(rcmp(r, head, tail) == 0){
	  				reuse = 1;
	  				break;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/rule.c:34,40 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/rule.c:34,40
	  	r->rule = nrules++;
	  
	  	if(!reuse){
	- 		rr = (Rule *)symlook(head, S_TARGET, (void *)r)->value;
	+ 		rr = symlook(head, S_TARGET, r)->u.ptr;
	  		if(rr != r){
	  			r->chain = rr->chain;
	  			rr->chain = r;
 [rsc] --rw-rw-r-- M 451989 glenda sys 5063 Nov  6 10:05 sys/src/cmd/mk/run.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/run.c:169,175 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/run.c:169,175
	  	for(w = j->t; w; w = w->next){
	  		if((s = symlook(w->s, S_NODE, 0)) == 0)
	  			continue;	/* not interested in this node */
	- 		update(uarg, (Node *)s->value);
	+ 		update(uarg, s->u.ptr);
	  	}
	  	if(nrunning < nproclimit)
	  		sched();
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/run.c:183,189 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/run.c:183,189
	  	Word *w;
	  
	  	if(sym = symlook("NPROC", S_VAR, 0)) {
	- 		w = (Word *) sym->value;
	+ 		w = sym->u.ptr;
	  		if (w && w->s && w->s[0])
	  			nproclimit = atoi(w->s);
	  	}
 [rsc] --rw-rw-r-- M 451989 glenda sys 1581 Nov  6 10:05 sys/src/cmd/mk/symtab.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/symtab.c:36,42 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/symtab.c:36,42
	  	s = (Symtab *)Malloc(sizeof(Symtab));
	  	s->space = space;
	  	s->name = sym;
	- 	s->value = install;
	+ 	s->u.ptr = install;
	  	s->next = hash[h];
	  	hash[h] = s;
	  	return(s);
 [rsc] --rw-rw-r-- M 451989 glenda sys 530 Nov  6 10:05 sys/src/cmd/mk/var.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/var.c:3,9 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/var.c:3,9
	  void
	  setvar(char *name, void *value)
	  {
	- 	symlook(name, S_VAR, value)->value = value;
	+ 	symlook(name, S_VAR, value)->u.ptr = value;
	  	symlook(name, S_MAKEVAR, (void*)"");
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/var.c:13,19 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/var.c:13,19
	  	Word *w;
	  
	  	Bprint(&bout, "\t%s=", s->name);
	- 	for (w = (Word *) s->value; w; w = w->next)
	+ 	for (w = s->u.ptr; w; w = w->next)
	  		Bprint(&bout, "'%s'", w->s);
	  	Bprint(&bout, "\n");
	  }
 [rsc] --rw-rw-r-- M 451989 glenda sys 4425 Nov  6 10:05 sys/src/cmd/mk/varsub.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/varsub.c:66,72 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/varsub.c:66,72
	  	sym = symlook(name, S_VAR, 0);
	  	if(sym){
	  			/* check for at least one non-NULL value */
	- 		for (w = (Word*)sym->value; w; w = w->next)
	+ 		for (w = sym->u.ptr; w; w = w->next)
	  			if(w->s && *w->s)
	  				return wdup(w);
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/varsub.c:113,122 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/varsub.c:113,122
	  	*s = end+1;
	  	
	  	sym = symlook(buf->start, S_VAR, 0);
	- 	if(sym == 0 || sym->value == 0)
	+ 	if(sym == 0 || sym->u.value == 0)
	  		w = newword(buf->start);
	  	else
	- 		w = subsub((Word*) sym->value, cp, end);
	+ 		w = subsub(sym->u.ptr, cp, end);
	  	freebuf(buf);
	  	return w;
	  }

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 7964 Nov  6 10:04 sys/src/cmd/rdbfs.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/rdbfs.c:275,281 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/rdbfs.c:275,281
	  {
	  	char buf[ERRMAX];
	  
	- 	switch((int)r->fid->file->aux){
	+ 	switch((uintptr)r->fid->file->aux){
	  	case Xtext:
	  		close(textfd);
	  		textfd = open(textfile, OREAD);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/rdbfs.c:295,301 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/rdbfs.c:295,301
	  	int i, n;
	  	char buf[512];
	  
	- 	switch((int)r->fid->file->aux) {
	+ 	switch((uintptr)r->fid->file->aux) {
	  	case Xfpregs:
	  	case Xproc:
	  	case Xregs:
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/rdbfs.c:336,342 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/rdbfs.c:336,342
	  {
	  	char buf[ERRMAX];
	  
	- 	switch((int)r->fid->file->aux) {
	+ 	switch((uintptr)r->fid->file->aux) {
	  	case Xctl:
	  		if(strncmp(r->ifcall.data, "kill", 4) == 0 ||
	  		   strncmp(r->ifcall.data, "exit", 4) == 0) {

64-bit fixes.
 [jmk] --rw-rw-r-- M 451989 glenda sys 4377 Nov  6 12:25 sys/src/cmd/db/command.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/command.c:150,156 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/command.c:150,156
	  			map = symmap;
	  	}
	  	if (!map) {
	- 		sprint(buf, "no map for %c", pc);
	+ 		snprint(buf, sizeof(buf), "no map for %c", pc);
	  		error(buf);
	  	}
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/command.c:186,192 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/command.c:186,192
	  void
	  cmdsrc(int c, Map *map)
	  {
	- 	long w;
	+ 	ulong w;
	  	long locval, locmsk;
	  	ADDR savdot;
	  	ushort sh;
 [rsc] --rw-rw-r-- M 451989 glenda sys 1700 Nov  6 11:02 sys/src/cmd/db/defs.h
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/defs.h:10,17 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/defs.h:10,17
	  
	  #include <mach.h>
	  
	- typedef long WORD;
	- typedef vlong ADDR;
	+ typedef ulong WORD;
	+ typedef uvlong ADDR;
	  
	  #define	HUGEINT	0x7fffffff	/* enormous WORD */
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/defs.h:57,62 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/defs.h:57,63
	  #define BKPTSKIP 2	/* real, skip over it next time */
	  #define	BKPTTMP	3	/* temporary; clear when it happens */
	  
	+ typedef struct bkpt	BKPT;
	  struct bkpt {
	  	ADDR	loc;
	  	uchar	save[4];
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/defs.h:64,72 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/defs.h:65,72
	  	int	initcnt;
	  	int	flag;
	  	char	comm[MAXCOM];
	- 	struct bkpt *nxtbkpt;
	+ 	BKPT	*nxtbkpt;
	  };
	- typedef struct bkpt	BKPT;
	  
	  #define	BADREG	(-1)
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/defs.h:75,81 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/defs.h:75,81
	   */
	  
	  extern	WORD	adrval;
	- extern	vlong	expv;
	+ extern	uvlong	expv;
	  extern	int	adrflg;
	  extern	WORD	cntval;
	  extern	int	cntflg;
 [rsc] --rw-rw-r-- M 451989 glenda sys 5441 Nov  6 11:02 sys/src/cmd/db/expr.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/expr.c:10,16 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/expr.c:10,16
	  static long	round(long, long);
	  
	  extern	ADDR	ditto;
	- vlong	expv;
	+ uvlong	expv;
	  
	  static WORD
	  ascval(void)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/expr.c:119,131 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/expr.c:119,131
	  
	  term(int a)
	  {	/* item | monadic item | (expr) | */
	- 	WORD e;
	+ 	ADDR e;
	  
	  	switch ((int)readchar()) {
	  
	  	case '*':
	  		term(a|1);
	- 		if (get4(cormap, (ADDR)expv, &e) < 0)
	+ 		if (geta(cormap, expv, &e) < 0)
	  			error("%r");
	  		expv = e;
	  		return(1);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/expr.c:132,138 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/expr.c:132,138
	  
	  	case '@':
	  		term(a|1);
	- 		if (get4(symmap, (ADDR)expv, &e) < 0)
	+ 		if (geta(symmap, expv, &e) < 0)
	  			error("%r");
	  		expv = e;
	  		return(1);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/expr.c:163,169 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/expr.c:163,169
	  {	/* name [ . local ] | number | . | ^  | <register | 'x | | */
	  	char	*base;
	  	char	savc;
	- 	WORD e;
	+ 	uvlong e;
	  	Symbol s;
	  	char gsym[MAXSYM], lsym[MAXSYM];
	  
 [jmk] --rw-rw-r-- M 451989 glenda sys 2014 Nov  6 12:25 sys/src/cmd/db/fns.h
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/fns.h:24,33 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/fns.h:24,29
	  void		execbkpt(BKPT*, int);
	  char*		exform(int, int, char*, Map*, int, int);
	  int		expr(int);
	- /*
	- void		fixregs(Map*);
	- void		adjustreg(char*, ulong, long);
	- */
	  void		flush(void);
	  void		flushbuf(void);
	  char*		getfname(void);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/fns.h:35,41 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/fns.h:31,37
	  int		getnum(int (*)(void));
	  void		grab(void);
	  void		iclose(int, int);
	- ADDR		inkdot(long);
	+ ADDR		inkdot(WORD);
	  int		isfileref(void);
	  int		item(int);
	  void		killpcs(void);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/fns.h:55,61 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/fns.h:51,57
	  void		printpc(void);
	  void		printregs(int);
	  void		prints(char*);
	- void		printsource(long);
	+ void		printsource(ADDR);
	  void		printsym(void);
	  void		printsyscall(void);
	  void		printtrace(int);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/fns.h:68,79 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/fns.h:64,75
	  void		readfname(char *);
	  void		reread(void);
	  char*		regname(int);
	- vlong		rget(Map*, char*);
	+ uvlong		rget(Map*, char*);
	  Reglist*	rname(char*);
	  void		rput(Map*, char*, vlong);
	  int		runpcs(int, int);
	  void		runrun(int);
	- void		runstep(ulong, int);
	+ void		runstep(uvlong, int);
	  BKPT*		scanbkpt(ADDR adr);
	  void		scanform(long, int, char*, Map*, int);
	  void		setbp(void);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/fns.h:88,90 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/fns.h:84,89
	  int		term(int);
	  void		ungrab(void);
	  int		valpr(long, int);
	+ 
	+ #pragma	varargck	argpos	dprint	1
	+ #pragma	varargck	type	"t"	void
 [jmk] --rw-rw-r-- M 451989 glenda sys 6868 Nov  6 12:25 sys/src/cmd/db/format.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/format.c:51,59 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/format.c:51,59
	  	 * sets `dotinc' and moves `dot'
	  	 * returns address of next format item
	  	 */
	- 	vlong	v;
	- 	long	w;
	- 	ulong	savdot;
	+ 	uvlong	v;
	+ 	ulong	w;
	+ 	ADDR	savdot;
	  	char	*fp;
	  	char	c, modifier;
	  	int	i;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/format.c:102,108 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/format.c:102,108
	  			break;
	  
	  		case 'A':
	- 			dprint("%#lux%10t", dot);
	+ 			dprint("%#llux%10t", dot);
	  			dotinc = 0;
	  			break;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/format.c:294,300 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/format.c:294,300
	  		case 'f':
	  			/* BUG: 'f' and 'F' assume szdouble is sizeof(vlong) in the literal case */
	  			if (literal) {
	- 				v = machdata->swav((ulong)dot);
	+ 				v = machdata->swav(dot);
	  				memmove(buf, &v, mach->szfloat);
	  			}else if (get1(map, dot, (uchar*)buf, mach->szfloat) < 0)
	  				error("%r");
 [jmk] --rw-rw-r-- M 451989 glenda sys 5949 Nov  6 12:25 sys/src/cmd/db/print.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:20,26 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:20,26
	   *	callback on stack trace
	   */
	  static void
	- ptrace(Map *map, ulong pc, ulong sp, Symbol *sym)
	+ ptrace(Map *map, uvlong pc, uvlong sp, Symbol *sym)
	  {
	  	char buf[512];
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:41,53 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:41,53
	  void
	  printtrace(int modif)
	  {
	- 	int	i;
	- 	ulong pc, sp, link;
	- 	long v;
	+ 	int i;
	+ 	uvlong pc, sp, link;
	+ 	ulong w;
	  	BKPT *bk;
	  	Symbol s;
	- 	int	stack;
	- 	char	*fname;
	+ 	int stack;
	+ 	char *fname;
	  	char buf[512];
	  
	  	if (cntflg==0)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:127,135 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:127,140
	  	case 'C':
	  		tracetype = modif;
	  		if (machdata->ctrace) {
	- 			if (adrflg) {	/* trace from jmpbuf for multi-threaded code */
	- 				if (get4(cormap, adrval, (long*)&sp) < 0 ||
	- 					get4(cormap, adrval+4, (long*)&pc) < 0)
	+ 			if (adrflg) {
	+ 				/*
	+ 				 * trace from jmpbuf for multi-threaded code.
	+ 				 * assume sp and pc are in adjacent locations
	+ 				 * and mach->szaddr in size.
	+ 				 */
	+ 				if (geta(cormap, adrval, &sp) < 0 ||
	+ 					geta(cormap, adrval+mach->szaddr, &pc) < 0)
	  						error("%r");
	  			} else {
	  				sp = rget(cormap, mach->sp);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:147,154 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:152,159
	  		/*print externals*/
	  	case 'e':
	  		for (i = 0; globalsym(&s, i); i++) {
	- 			if (get4(cormap, s.value, &v) > 0)
	- 				dprint("%s/%12t%#lux\n", s.name,	v);
	+ 			if (get4(cormap, s.value, &w) > 0)
	+ 				dprint("%s/%12t%#lux\n", s.name, w);
	  		}
	  		break;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:226,232 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:231,237
	  void
	  redirin(int stack, char *file)
	  {
	- 	char pfile[ARB];
	+ 	char *pfile;
	  
	  	if (file == 0) {
	  		iclose(-1, 0);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:234,243 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:239,248
	  	}
	  	iclose(stack, 0);
	  	if ((infile = open(file, 0)) < 0) {
	- 		strcpy(pfile, Ipath);
	- 		strcat(pfile, "/");
	- 		strcat(pfile, file);
	- 		if ((infile = open(pfile, 0)) < 0) {
	+ 		pfile = smprint("%s/%s", Ipath, file);
	+ 		infile = open(pfile, 0);
	+ 		free(pfile);
	+ 		if(infile < 0) {
	  			infile = STDIN;
	  			error("cannot open");
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:259,266 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:264,272
	  		dprint("%s\n", s);
	  	for (i = 0; i < map->nsegs; i++) {
	  		if (map->seg[i].inuse)
	- 			dprint("%s%8t%-16#lux %-16#lux %-16#lux\n", map->seg[i].name,
	- 				map->seg[i].b, map->seg[i].e, map->seg[i].f);
	+ 			dprint("%s%8t%-16#llux %-16#llux %-16#llux\n",
	+ 				map->seg[i].name, map->seg[i].b,
	+ 				map->seg[i].e, map->seg[i].f);
	  	}
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:277,287 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:283,293
	  		switch(sp->type) {
	  		case 't':
	  		case 'l':
	- 			dprint("%8#lux t %s\n", sp->value, sp->name);
	+ 			dprint("%16#llux t %s\n", sp->value, sp->name);
	  			break;
	  		case 'T':
	  		case 'L':
	- 			dprint("%8#lux T %s\n", sp->value, sp->name);
	+ 			dprint("%16#llux T %s\n", sp->value, sp->name);
	  			break;
	  		case 'D':
	  		case 'd':
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:290,296 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:296,302
	  		case 'a':
	  		case 'p':
	  		case 'm':
	- 			dprint("%8#lux %c %s\n", sp->value, sp->type, sp->name);
	+ 			dprint("%16#llux %c %s\n", sp->value, sp->type, sp->name);
	  			break;
	  		default:
	  			break;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:304,310 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:310,316
	   *	print the value of dot as file:line
	   */
	  void
	- printsource(long dot)
	+ printsource(ADDR dot)
	  {
	  	char str[STRINGSZ];
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:317,323 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:323,329
	  {
	  	char buf[512];
	  
	- 	dot = (ulong)rget(cormap, mach->pc);
	+ 	dot = rget(cormap, mach->pc);
	  	if(dot){
	  		printsource((long)dot);
	  		printc(' ');
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:333,339 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:339,345
	  printlocals(Symbol *fn, ADDR fp)
	  {
	  	int i;
	- 	long val;
	+ 	ulong w;
	  	Symbol s;
	  
	  	s = *fn;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:340,347 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:346,353
	  	for (i = 0; localsym(&s, i); i++) {
	  		if (s.class != CAUTO)
	  			continue;
	- 		if (get4(cormap, fp-s.value, &val) > 0)
	- 			dprint("%8t%s.%s/%10t%#lux\n", fn->name, s.name, val);
	+ 		if (get4(cormap, fp-s.value, &w) > 0)
	+ 			dprint("%8t%s.%s/%10t%#lux\n", fn->name, s.name, w);
	  		else
	  			dprint("%8t%s.%s/%10t?\n", fn->name, s.name);
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:352,358 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:358,364
	  {
	  	int i;
	  	Symbol s;
	- 	long v;
	+ 	ulong w;
	  	int first = 0;
	  
	  	fp += mach->szaddr;			/* skip saved pc */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/print.c:362,368 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/print.c:368,374
	  			continue;
	  		if (first++)
	  			dprint(", ");
	- 		if (get4(cormap, fp+s.value, &v) > 0)
	- 			dprint("%s=%#lux", s.name, v);
	+ 		if (get4(cormap, fp+s.value, &w) > 0)
	+ 			dprint("%s=%#lux", s.name, w);
	  	}
	  }
 [jmk] --rw-rw-r-- M 451989 glenda sys 1998 Nov  6 12:25 sys/src/cmd/db/regs.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/regs.c:19,29 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/regs.c:19,30
	  	return 0;
	  }
	  
	- static vlong
	+ static uvlong
	  getreg(Map *map, Reglist *rp)
	  {
	- 	vlong v;
	- 	long w;
	+ 	uvlong v;
	+ 	ulong w;
	+ 	ushort s;
	  	int ret;
	  
	  	v = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/regs.c:31,42 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/regs.c:32,43
	  	switch (rp->rformat)
	  	{
	  	case 'x':
	- 		ret = get2(map, rp->roffs, (ushort*) &w);
	- 		v = w;
	+ 		ret = get2(map, rp->roffs, &s);
	+ 		v = s;
	  		break;
	  	case 'f':
	  	case 'X':
	- 		ret = get4(map, rp->roffs, (long*) &w);
	+ 		ret = get4(map, rp->roffs, &w);
	  		v = w;
	  		break;
	  	case 'F':
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/regs.c:55,61 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/regs.c:56,62
	  	return v;
	  }
	  
	- vlong
	+ uvlong
	  rget(Map *map, char *name)
	  {
	  	Reglist *rp;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/regs.c:104,109 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/regs.c:105,111
	  {
	  	Reglist *rp;
	  	int i;
	+ 	uvlong v;
	  
	  	for (i = 1, rp = mach->reglist; rp->rname; rp++, i++) {
	  		if ((rp->rflags & RFLT)) {
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/regs.c:112,121 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/regs.c:114,124
	  			if (rp->rformat == '8' || rp->rformat == '3')
	  				continue;
	  		}
	+ 		v = getreg(cormap, rp);
	  		if(rp->rformat == 'Y')
	- 			dprint("%-8s %-20#llux", rp->rname, getreg(cormap, rp));
	+ 			dprint("%-8s %-20#llux", rp->rname, v);
	  		else
	- 			dprint("%-8s %-12#lux", rp->rname, (ulong)getreg(cormap, rp));
	+ 			dprint("%-8s %-12#lux", rp->rname, (ulong)v);
	  		if ((i % 3) == 0) {
	  			dprint("\n");
	  			i = 0;
 [jmk] --rw-rw-r-- M 451989 glenda sys 4433 Nov  6 12:25 sys/src/cmd/db/trcrun.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/trcrun.c:205,214 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/trcrun.c:205,214
	  }
	  
	  void
	- runstep(ulong loc, int keepnote)
	+ runstep(uvlong loc, int keepnote)
	  {
	  	int nfoll;
	- 	ulong foll[3];
	+ 	uvlong foll[3];
	  	BKPT bkpt[3];
	  	int i;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/db/trcrun.c:264,270 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/db/trcrun.c:264,270
	  bkput(BKPT *bp, int install)
	  {
	  	char buf[256];
	- 	ulong loc;
	+ 	ADDR loc;
	  	int ret;
	  
	  	errstr(buf, sizeof buf);
 [jmk] --rw-rw-r-- M 451989 glenda sys 4377 Nov  6 12:25 sys/src/cmd/db/command.c
 [jmk] --rw-rw-r-- M 451989 glenda sys 2014 Nov  6 12:25 sys/src/cmd/db/fns.h
 [jmk] --rw-rw-r-- M 451989 glenda sys 6868 Nov  6 12:25 sys/src/cmd/db/format.c
 [jmk] --rw-rw-r-- M 451989 glenda sys 5949 Nov  6 12:25 sys/src/cmd/db/print.c
 [jmk] --rw-rw-r-- M 451989 glenda sys 1998 Nov  6 12:25 sys/src/cmd/db/regs.c
 [jmk] --rw-rw-r-- M 451989 glenda sys 4433 Nov  6 12:25 sys/src/cmd/db/trcrun.c

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 4837 Nov  6 11:02 sys/src/cmd/vi/mips.h
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/vi/mips.h:193,199 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/vi/mips.h:193,199
	  void		initstk(int, char**);
	  void		reset(void);
	  void		dobplist(void);
	- int		_mipscoinst(Map*, ulong, char*, int);
	+ int		_mipscoinst(Map*, uvlong, char*, int);
	  void		procinit(int);
	  void		printsource(long);
	  void		printparams(Symbol *, ulong);

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 4914 Nov  6 11:02 sys/src/cmd/nm.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/nm.c:265,271 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/nm.c:265,271
	  		} else
	  			cp = s->name;
	  		if (s->value || s->type == 'a' || s->type == 'p')
	- 			Bprint(&bout, "%8lux %c %s\n", s->value, s->type, cp);
	+ 			Bprint(&bout, "%16llux %c %s\n", s->value, s->type, cp);
	  		else
	  			Bprint(&bout, "         %c %s\n", s->type, cp);
	  	}

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 1407 Nov  6 11:07 sys/include/a.out.h
	/n/sourcesdump/2005/1106/plan9/sys/include/a.out.h:11,41 - 
	/n/sourcesdump/2005/1107/plan9/sys/include/a.out.h:11,44
	  	long	pcsz;		/* size of pc/line number table */
	  };
	  
	- #define	_MAGIC(b)	((((4*b)+0)*b)+7)
	- #define	A_MAGIC		_MAGIC(8)	/* 68020 */
	- #define	I_MAGIC		_MAGIC(11)	/* intel 386 */
	- #define	J_MAGIC		_MAGIC(12)	/* intel 960 (retired) */
	- #define	K_MAGIC		_MAGIC(13)	/* sparc */
	- #define	V_MAGIC		_MAGIC(16)	/* mips 3000 BE */
	- #define	X_MAGIC		_MAGIC(17)	/* att dsp 3210 (retired) */
	- #define	M_MAGIC		_MAGIC(18)	/* mips 4000 BE */
	- #define	D_MAGIC		_MAGIC(19)	/* amd 29000 (retired) */
	- #define	E_MAGIC		_MAGIC(20)	/* arm */
	- #define	Q_MAGIC		_MAGIC(21)	/* powerpc */
	- #define	N_MAGIC		_MAGIC(22)	/* mips 4000 LE */
	- #define	L_MAGIC		_MAGIC(23)	/* dec alpha */
	- #define	P_MAGIC		_MAGIC(24)	/* mips 3000 LE */
	- #define	U_MAGIC		_MAGIC(25)	/* sparc64 */
	- #define	S_MAGIC		_MAGIC(26)	/* amd64 */
	+ #define HDR_MAGIC	0x00008000		/* header expansion */
	+ 
	+ #define	_MAGIC(f, b)	((f)|((((4*(b))+0)*(b))+7))
	+ #define	A_MAGIC		_MAGIC(0, 8)		/* 68020 */
	+ #define	I_MAGIC		_MAGIC(0, 11)		/* intel 386 */
	+ #define	J_MAGIC		_MAGIC(0, 12)		/* intel 960 (retired) */
	+ #define	K_MAGIC		_MAGIC(0, 13)		/* sparc */
	+ #define	V_MAGIC		_MAGIC(0, 16)		/* mips 3000 BE */
	+ #define	X_MAGIC		_MAGIC(0, 17)		/* att dsp 3210 (retired) */
	+ #define	M_MAGIC		_MAGIC(0, 18)		/* mips 4000 BE */
	+ #define	D_MAGIC		_MAGIC(0, 19)		/* amd 29000 (retired) */
	+ #define	E_MAGIC		_MAGIC(0, 20)		/* arm */
	+ #define	Q_MAGIC		_MAGIC(0, 21)		/* powerpc */
	+ #define	N_MAGIC		_MAGIC(0, 22)		/* mips 4000 LE */
	+ #define	L_MAGIC		_MAGIC(0, 23)		/* dec alpha */
	+ #define	P_MAGIC		_MAGIC(0, 24)		/* mips 3000 LE */
	+ #define	U_MAGIC		_MAGIC(0, 25)		/* sparc64 */
	+ #define	S_MAGIC		_MAGIC(HDR_MAGIC, 26)	/* amd64 */
	+ 
	  #define	MIN_MAGIC	8
	- #define	MAX_MAGIC	26
	+ #define	MAX_MAGIC	26			/* <= 90 */
	  
	- #define	DYN_MAGIC	0x80000000	/* or'd in for dynamically loaded modules */
	+ #define	DYN_MAGIC	0x80000000		/* dlm */
	  
	  typedef	struct	Sym	Sym;
	  struct	Sym
	  {
	- 	long	value;
	+ 	vlong	value;
	  	char	type;
	  	char	*name;
	  };

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 523 Nov  6 11:07 sys/man/1/strip
	/n/sourcesdump/2005/1106/plan9/sys/man/1/strip:3,18 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/1/strip:3,30
	  strip \- remove symbols from binary files
	  .SH SYNOPSIS
	  .B strip
	- [
	  .I file ...
	- ]
	+ .PP
	+ .B strip
	+ .B -o
	+ .I ofile
	+ .I file
	  .SH DESCRIPTION
	  .I Strip
	- removes symbol table segments from executable files, rewriting the files in place.
	+ removes symbol table segments from executable files,
	+ rewriting the files in place.
	  Stripping a file requires write permission of the file
	  and the directory it is in.
	- If no file is given, 
	- standard input is stripped and the result written to standard output.
	+ .PP
	+ If the
	+ .B -o
	+ flag is given, 
	+ the single input file
	+ .I file
	+ is stripped and the result written to
	+ .IR ofile .
	+ .I File
	+ is unchanged.
	  .SH SOURCE
	  .B /sys/src/cmd/strip.c
	  .SH "SEE ALSO"
 [rsc] --rw-rw-r-- M 451989 glenda sys 2502 Nov  6 11:07 sys/src/cmd/strip.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/strip.c:1,206 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/strip.c:1,170
	  #include <u.h>
	  #include <libc.h>
	- #include <a.out.h>
	+ #include <bio.h>
	+ #include <mach.h>
	  
	- int	strip(char*);
	- int	stripfilt(int, int);
	  void
	- main(int argc, char *argv[])
	+ error(char* fmt, ...)
	  {
	- 	int i;
	- 	int rv;
	+ 	va_list arg;
	+ 	char *e, s[256];
	  
	- 	rv = 0;
	+ 	va_start(arg, fmt);
	+ 	e = seprint(s, s+sizeof(s), "%s: ", argv0);
	+ 	e = vseprint(e, s+sizeof(s), fmt, arg);
	+ 	e = seprint(e, s+sizeof(s), "\n");
	+ 	va_end(arg);
	  
	- 	if(argc == 1) {
	- 		if(stripfilt(0, 1))
	- 			exits("error");
	- 		exits(0);
	- 	}
	- 
	- 	for(i = 1; i < argc; i++)
	- 		rv |= strip(argv[i]);
	- 	if(rv)
	- 		exits("error");
	- 	exits(0);
	+ 	write(2, s, e-s);
	  }
	  
	- long
	- ben(long xen)
	+ static void
	+ usage(void)
	  {
	- 	union
	- 	{
	- 		long	xen;
	- 		uchar	uch[sizeof(long)];
	- 	} u;
	- 
	- 	u.xen = xen;
	- 	return (u.uch[0] << 24) | (u.uch[1] << 16) | (u.uch[2] << 8) | (u.uch[3] << 0);
	+ 	error("usage: %s -o ofile file\n\t%s file ...\n", argv0, argv0);
	+ 	exits("usage");
	  }
	  
	- int
	- stripfilt(int in, int out)
	+ static int
	+ strip(char* file, char* out)
	  {
	- 	Exec exec;
	- 	int i, j, n, m, len;
	- 	char buf[8192];
	+ 	Dir *dir;
	+ 	int fd, i;
	+ 	Fhdr fhdr;
	+ 	Exec *exec;
	+ 	ulong mode;
	+ 	void *data;
	+ 	vlong length;
	  
	- 	/*
	- 	 * read header
	- 	 */
	- 
	- 	if(readn(in, &exec, sizeof(Exec)) != sizeof(Exec)) {
	- 		fprint(2, "strip: short read\n");
	+ 	if((fd = open(file, OREAD)) < 0){
	+ 		error("%s: open: %r", file);
	  		return 1;
	  	}
	- 	i = ben(exec.magic);
	- 	for (j = MIN_MAGIC; j <= MAX_MAGIC; j++)
	- 		if (i == _MAGIC(j))
	- 			break;
	- 	if (j > MAX_MAGIC) {
	- 		fprint(2, "strip: not a recognizable binary\n");
	- 		return 1;
	- 	}
	  
	- 	len = ben(exec.data) + ben(exec.text);
	- 
	- 	/*
	- 	 *  copy exec, text and data
	- 	 */
	- 	exec.syms = 0;
	- 	exec.spsz = 0;
	- 	exec.pcsz = 0;
	- 	write(out, &exec, sizeof(exec));
	- 	
	- 	for(n=0; n<len; n+=m) {
	- 		m = len - n;
	- 		if(m > sizeof(buf))
	- 			m = sizeof(buf);
	- 		if((m = read(in, buf, m)) < 0) {
	- 			fprint(2, "strip: premature eof: %r\n");
	- 			return 1;
	- 		}
	- 		if(write(out, buf, m) != m) {
	- 			fprint(2, "strip: write error; %r\n");
	- 			return 1;
	- 		}
	- 	}
	- 
	- 	return 0;
	- }
	- 
	- 
	- int
	- strip(char *file)
	- {
	- 	int fd;
	- 	Exec exec;
	- 	char *data;
	- 	Dir *d;
	- 	long n, len;
	- 	int i, j;
	- 
	- 	/*
	- 	 *  make sure file is executable
	- 	 */
	- 	d = dirstat(file);
	- 	if(d == nil){
	- 		perror(file);
	+ 	if(!crackhdr(fd, &fhdr)){
	+ 		error("%s: %r", file);
	+ 		close(fd);
	  		return 1;
	  	}
	- 	if((d->qid.path & (DMDIR|DMAPPEND|DMEXCL))){
	- 		fprint(2, "strip: %s must be executable\n", file);
	- 		return 1;
	+ 	for(i = MIN_MAGIC; i <= MAX_MAGIC; i++){
	+ 		if(fhdr.magic == _MAGIC(0, i) || fhdr.magic == _MAGIC(HDR_MAGIC, i))
	+ 			break;
	  	}
	- 	/*
	- 	 *  read its header and see if that makes sense
	- 	 */
	- 	fd = open(file, OREAD);
	- 	if(fd < 0){
	- 		perror(file);
	- 		free(d);
	- 		return 1;
	- 	}
	- 	n = read(fd, &exec, sizeof exec);
	- 	if (n != sizeof(exec)) {
	- 		fprint(2, "strip: Unable to read header of %s\n", file);
	+ 	if(i > MAX_MAGIC){
	+ 		error("%s: not a recognizeable binary", file);
	  		close(fd);
	- 		free(d);
	  		return 1;
	  	}
	- 	i = ben(exec.magic);
	- 	for (j = MIN_MAGIC; j <= MAX_MAGIC; j++)
	- 		if (i == _MAGIC(j))
	- 			break;
	- 	if (j > MAX_MAGIC) {
	- 		fprint(2, "strip: %s is not a recognizable binary\n", file);
	+ 
	+ 	if((dir = dirfstat(fd)) == nil){
	+ 		error("%s: stat: %r", file);
	  		close(fd);
	- 		free(d);
	  		return 1;
	  	}
	  
	- 	len = ben(exec.data) + ben(exec.text);
	- 	if(len+sizeof(exec) == d->length) {
	- 		fprint(2, "strip: %s is already stripped\n", file);
	- 		close(fd);
	- 		free(d);
	- 		return 0;
	+ 	length = fhdr.datoff+fhdr.datsz;
	+ 	if(length == dir->length){
	+ 		if(out == nil){	/* nothing to do */
	+ 			error("%s: already stripped", file);
	+ 			free(dir);
	+ 			close(fd);
	+ 			return 0;
	+ 		}
	  	}
	- 	if(len+sizeof(exec) > d->length) {
	- 		fprint(2, "strip: %s has strange length\n", file);
	+ 	if(length > dir->length){
	+ 		error("%s: strange length", file);
	  		close(fd);
	- 		free(d);
	+ 		free(dir);
	  		return 1;
	  	}
	- 	/*
	- 	 *  allocate a huge buffer, copy the header into it, then
	- 	 *  read the file.
	- 	 */
	- 	data = malloc(len+sizeof(exec));
	- 	if (!data) {
	- 		fprint(2, "strip: Malloc failure. %s too big to strip.\n", file);
	+ 
	+ 	mode = dir->mode;
	+ 	free(dir);
	+ 
	+ 	if((data = malloc(length)) == nil){
	+ 		error("%s: malloc failure", file);
	  		close(fd);
	- 		free(d);
	  		return 1;
	  	}
	- 	/*
	- 	 *  copy exec, text and data
	- 	 */
	- 	exec.syms = 0;
	- 	exec.spsz = 0;
	- 	exec.pcsz = 0;
	- 	memcpy(data, &exec, sizeof(exec));
	- 	n = read(fd, data+sizeof(exec), len);
	- 	if (n != len) {
	- 		perror(file);
	+ 	seek(fd, 0LL, 0);
	+ 	if(read(fd, data, length) != length){
	+ 		error("%s: read: %r", file);
	  		close(fd);
	- 		free(d);
	+ 		free(data);
	  		return 1;
	  	}
	  	close(fd);
	- 	if(remove(file) < 0) {
	- 		perror(file);
	- 		free(data);
	- 		free(d);
	- 		return 1;
	+ 
	+ 	exec = data;
	+ 	exec->syms = 0;
	+ 	exec->spsz = 0;
	+ 	exec->pcsz = 0;
	+ 
	+ 	if(out == nil){
	+ 		if(remove(file) < 0) {
	+ 			error("%s: remove: %r", file);
	+ 			free(data);
	+ 			return 1;
	+ 		}
	+ 		out = file;
	  	}
	- 	fd = create(file, OWRITE, d->mode);
	- 	if (fd < 0) {
	- 		perror(file);
	+ 	if((fd = create(out, OWRITE, mode)) < 0){
	+ 		error("%s: create: %r", out);
	  		free(data);
	- 		free(d);
	  		return 1;
	  	}
	- 	n = write(fd, data, len+sizeof(exec));
	- 	if (n != len+sizeof(exec)) {
	- 		perror(file);
	+ 	if(write(fd, data, length) != length){
	+ 		error("%s: write: %r", out);
	  		close(fd);
	  		free(data);
	- 		free(d);
	  		return 1;
	- 	} 
	+ 	}
	  	close(fd);
	  	free(data);
	- 	free(d);
	+ 
	  	return 0;
	+ }
	+ 
	+ void
	+ main(int argc, char* argv[])
	+ {
	+ 	int r;
	+ 	char *p;
	+ 
	+ 	p = nil;
	+ 
	+ 	ARGBEGIN{
	+ 	default:
	+ 		usage();
	+ 		break;
	+ 	case 'o':
	+ 		p = ARGF();
	+ 		if(p == nil)
	+ 			usage();
	+ 		break;
	+ 	}ARGEND;
	+ 
	+ 	switch(argc){
	+ 	case 0:
	+ 		usage();
	+ 		return;
	+ 	case 1:
	+ 		if(p != nil){
	+ 			r = strip(*argv, p);
	+ 			break;
	+ 		}
	+ 		/*FALLTHROUGH*/
	+ 	default:
	+ 		r = 0;
	+ 		while(argc > 0){
	+ 			r |= strip(*argv, nil);
	+ 			argc--;
	+ 			argv++;
	+ 		}
	+ 		break;
	+ 	}
	+ 
	+ 	if(r)
	+ 		exits("error");
	+ 	exits(0);
	  }

More buffering changes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 23883 Nov  6 11:10 sys/src/cmd/cc/lex.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/cc/lex.c:188,193 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/cc/lex.c:188,194
	  		}
	  		Binit(&outbuf, c, OWRITE);
	  	}
	+ 	Binit(&diagbuf, 1, OWRITE);
	  	newio();
	  
	  	/* Use an ANSI preprocessor */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/cc/lex.c:232,238 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/cc/lex.c:233,239
	  			if(debug['p'] > 1) {
	  				for(c = 0; c < i; c++)
	  					fprint(2, "%s ", av[c]);
	- 				print("\n");
	+ 				fprint(2, "\n");
	  			}
	  			myexec(av[0], av);
	  			fprint(2, "can't exec C preprocessor %s: %r\n", CPP);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/cc/lex.c:1458,1464 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/cc/lex.c:1459,1465
	  {
	  	void *p;
	  
	- 	while((ulong)hunk & MAXALIGN) {
	+ 	while((uintptr)hunk & MAXALIGN) {
	  		hunk++;
	  		nhunk--;
	  	}
 [rsc] --rw-rw-r-- M 451989 glenda sys 9188 Nov  6 11:10 sys/src/cmd/cc/lexbody
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/cc/lexbody:45,51 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/cc/lexbody:45,51
	  {
	  	void *p;
	  
	- 	while((ulong)hunk & MAXALIGN) {
	+ 	while((uintptr)hunk & MAXALIGN) {
	  		hunk++;
	  		nhunk--;
	  	}

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 5885 Nov  6 11:07 sys/src/cmd/ktrace.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:4,13 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:4,13
	  #include <mach.h>
	  #include <ctype.h>
	  
	- static	int	rtrace(ulong, ulong, ulong);
	- static	int	ctrace(ulong, ulong, ulong);
	- static	int	i386trace(ulong, ulong, ulong);
	- static	ulong	getval(ulong);
	+ static	int	rtrace(uvlong, uvlong, uvlong);
	+ static	int	ctrace(uvlong, uvlong, uvlong);
	+ static	int	i386trace(uvlong, uvlong, uvlong);
	+ static	uvlong	getval(uvlong);
	  static	void	inithdr(int);
	  static	void	fatal(char*, ...);
	  static	void	readstack(void);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:25,31 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:25,31
	  }
	  
	  static void
	- printaddr(char *addr, ulong pc)
	+ printaddr(char *addr, uvlong pc)
	  {
	  	int i;
	  	char *p;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:42,48 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:42,48
	  			if(!isxdigit(addr[i]))
	  				break;
	  		if(i == 8){
	- 			print("src(0x%.8lux); // 0x%s\n", pc, addr);
	+ 			print("src(0x%.8llux); // 0x%s\n", pc, addr);
	  			return;
	  		}
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:49,66 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:49,66
	  
	  	if(p=strchr(addr, '+')){
	  		*p++ = 0;
	- 		print("src(0x%.8lux); // %s+0x%s\n", pc, addr, p);
	+ 		print("src(0x%.8llux); // %s+0x%s\n", pc, addr, p);
	  	}else
	- 		print("src(0x%.8lux); // %s\n", pc, addr);
	+ 		print("src(0x%.8llux); // %s\n", pc, addr);
	  }
	  
	- static void (*fmt)(char*, ulong) = printaddr;
	+ static void (*fmt)(char*, uvlong) = printaddr;
	  
	  void
	  main(int argc, char *argv[])
	  {
	- 	int (*t)(ulong, ulong, ulong);
	- 	ulong pc, sp, link;
	+ 	int (*t)(uvlong, uvlong, uvlong);
	+ 	uvlong pc, sp, link;
	  	int fd;
	  
	  	ARGBEGIN{
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:76,82 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:76,82
	  	switch(argc){
	  	case 4:
	  		t = rtrace;
	- 		link = strtoul(argv[3], 0, 16);
	+ 		link = strtoull(argv[3], 0, 16);
	  		break;
	  	case 3:
	  		break;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:83,90 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:83,90
	  	default:
	  		usage();
	  	}
	- 	pc = strtoul(argv[1], 0, 16);
	- 	sp = strtoul(argv[2], 0, 16);
	+ 	pc = strtoull(argv[1], 0, 16);
	+ 	sp = strtoull(argv[2], 0, 16);
	  	if(!interactive)
	  		readstack();
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:135,145 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:135,145
	  }
	  
	  static int
	- rtrace(ulong pc, ulong sp, ulong link)
	+ rtrace(uvlong pc, uvlong sp, uvlong link)
	  {
	  	Symbol s, f;
	  	char buf[128];
	- 	ulong oldpc;
	+ 	uvlong oldpc;
	  	int i;
	  
	  	i = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:175,187 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:175,187
	  }
	  
	  static int
	- ctrace(ulong pc, ulong sp, ulong link)
	+ ctrace(uvlong pc, uvlong sp, uvlong link)
	  {
	  	Symbol s;
	  	char buf[128];
	  	int found;
	- 	ulong opc;
	- 	long moved, j;
	+ 	uvlong opc, moved;
	+ 	long j;
	  
	  	USED(link);
	  	j = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:188,195 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:188,195
	  	opc = 0;
	  	while(pc && opc != pc) {
	  		moved = pc2sp(pc);
	- 		if (moved == -1){
	- 			print("pc2sp(%.8lux) = -1 %r\n", pc);
	+ 		if (moved == ~0){
	+ 			print("pc2sp(%.8llux) = -1 %r\n", pc);
	  			break;
	  		}
	  		found = findsym(pc, CTEXT, &s);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:213,222 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:213,222
	  }
	  
	  static int
	- i386trace(ulong pc, ulong sp, ulong link)
	+ i386trace(uvlong pc, uvlong sp, uvlong link)
	  {
	  	int i;
	- 	ulong osp;
	+ 	uvlong osp;
	  	Symbol s, f;
	  	char buf[128];
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:228,256 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:228,261
	  		symoff(buf, sizeof buf, pc, CANY);
	  		fmt(buf, pc);
	  
	+ //XXX		s.value &= ~(uintptr)0;
	  		if(pc != s.value) {	/* not at first instruction */
	  			if(findlocal(&s, FRAMENAME, &f) == 0)
	  				break;
	  			sp += f.value-mach->szaddr;
	  		}else if(strcmp(s.name, "forkret") == 0){
	- 			print("//passing interrupt frame; last pc found at sp=%lux\n", osp);
	+ //XXX
	+ 			print("//passing interrupt frame; last pc found at sp=%llux\n", osp);
	+ 
	  			sp +=  15 * mach->szaddr;		/* pop interrupt frame */
	  		}
	  
	  		pc = getval(sp);
	+ //XXX
	  		if(pc == 0 && strcmp(s.name, "forkret") == 0){
	  			sp += 3 * mach->szaddr;			/* pop iret eip, cs, eflags */
	- 			print("//guessing call through invalid pointer, try again at sp=%lux\n", sp);
	+ 			print("//guessing call through invalid pointer, try again at sp=%llux\n", sp);
	  			s.name = "";
	  			pc = getval(sp);
	  		}
	  		if(pc == 0) {
	- 			print("//didn't find pc at sp=%lux, last pc found at sp=%lux\n", sp, osp);
	+ 			print("//didn't find pc at sp=%llux, last pc found at sp=%llux\n", sp, osp);
	  			break;
	  		}
	  		osp = sp;
	  
	  		sp += mach->szaddr;
	+ //XXX
	  		if(strcmp(s.name, "forkret") == 0)
	  			sp += 2 * mach->szaddr;			/* pop iret cs, eflags */
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:261,271 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:266,276
	  }
	  
	  int naddr;
	- ulong addr[1024];
	- ulong val[1024];
	+ uvlong addr[1024];
	+ uvlong val[1024];
	  
	  static void
	- putval(ulong a, ulong v)
	+ putval(uvlong a, uvlong v)
	  {
	  	if(naddr < nelem(addr)){
	  		addr[naddr] = a;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ktrace.c:289,313 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ktrace.c:294,318
	  		for(i=0; i<nf; i++){
	  			if(p=strchr(f[i], '=')){
	  				*p++ = 0;
	- 				putval(strtoul(f[i], 0, 16), strtoul(p, 0, 16));
	+ 				putval(strtoull(f[i], 0, 16), strtoull(p, 0, 16));
	  			}
	  		}
	  	}
	  }
	  
	- static ulong
	- getval(ulong a)
	+ static uvlong
	+ getval(uvlong a)
	  {
	  	char buf[256];
	  	int i, n;
	  
	  	if(interactive){
	- 		print("// data at 0x%8.8lux? ", a);
	+ 		print("// data at 0x%8.8llux? ", a);
	  		n = read(0, buf, sizeof(buf)-1);
	  		if(n <= 0)
	  			return 0;
	  		buf[n] = '\0';
	- 		return strtoul(buf, 0, 16);
	+ 		return strtoull(buf, 0, 16);
	  	}else{
	  		for(i=0; i<naddr; i++)
	  			if(addr[i] == a)

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 7295 Nov  6 11:11 sys/src/cmd/tbl/t6.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t6.c:9,16 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t6.c:9,16
	  void
	  maktab(void)			/* define the tab stops of the table */
	  {
	- 	int	icol, ilin, tsep, k, ik, vforml, il, text;
	- 	char	*s;
	+ 	int	icol, ilin, tsep, k, ik, vforml, il, s, text;
	+ 	char	*ss;
	  
	  	for (icol = 0; icol < ncol; icol++) {
	  		doubled[icol] = acase[icol] = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t6.c:34,47 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t6.c:34,48
	  				switch (ctype(vforml, icol)) {
	  				case 'a':
	  					acase[icol] = 1;
	- 					s = table[ilin][icol].col;
	- 					if ((int)s > 0 && (int)s < 128 && text) {
	+ 					ss = table[ilin][icol].col;
	+ 					s = (int)(uintptr)ss;
	+ 					if (s > 0 && s < 128 && text) {
	  						if (doubled[icol] == 0)
	  							Bprint(&tabout, ".nr %d 0\n.nr %d 0\n",
	  							    S1, S2);
	  						doubled[icol] = 1;
	  						Bprint(&tabout, ".if \\n(%c->\\n(%d .nr %d \\n(%c-\n",
	- 						    (int)s, S2, S2, (int)s);
	+ 						    s, S2, S2, (int)s);
	  					}
	  				case 'n':
	  					if (table[ilin][icol].rcol != 0) {
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t6.c:49,66 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t6.c:50,68
	  							Bprint(&tabout, ".nr %d 0\n.nr %d 0\n",
	  							    S1, S2);
	  						doubled[icol] = 1;
	- 						if (real(s = table[ilin][icol].col) && !vspen(s)) {
	- 							if (tx((int)s) != text) 
	+ 						if (real(ss = table[ilin][icol].col) && !vspen(ss)) {
	+ 							s = (int)(uintptr)ss;
	+ 							if (tx(s) != text) 
	  								continue;
	  							Bprint(&tabout, ".nr %d ", TMP);
	- 							wide(s, FN(vforml, icol), SZ(vforml, icol)); 
	+ 							wide(ss, FN(vforml, icol), SZ(vforml, icol)); 
	  							Bprint(&tabout, "\n");
	  							Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n",
	  							    S1, TMP, S1, TMP);
	  						}
	- 						if (text == 0 && real(s = table[ilin][icol].rcol) && !vspen(s) && !barent(s)) {
	+ 						if (text == 0 && real(ss = table[ilin][icol].rcol) && !vspen(ss) && !barent(ss)) {
	  							Bprint(&tabout, ".nr %d \\w%c%s%c\n",
	- 							    TMP, F1, s, F1);
	+ 							    TMP, F1, ss, F1);
	  							Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S2, TMP, S2,
	  							     TMP);
	  						}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t6.c:69,79 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t6.c:71,82
	  				case 'r':
	  				case 'c':
	  				case 'l':
	- 					if (real(s = table[ilin][icol].col) && !vspen(s)) {
	- 						if (tx((int)s) != text) 
	+ 					if (real(ss = table[ilin][icol].col) && !vspen(ss)) {
	+ 						s = (int)(uintptr)ss;
	+ 						if (tx(s) != text) 
	  							continue;
	  						Bprint(&tabout, ".nr %d ", TMP);
	- 						wide(s, FN(vforml, icol), SZ(vforml, icol)); 
	+ 						wide(ss, FN(vforml, icol), SZ(vforml, icol)); 
	  						Bprint(&tabout, "\n");
	  						Bprint(&tabout, ".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n",
	  						     reg(icol, CRIGHT), TMP, reg(icol, CRIGHT), TMP);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t6.c:100,107 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t6.c:103,110
	  		}
	  		for (ilin = 0; ilin < nlin; ilin++)
	  			if (k = lspan(ilin, icol)) {
	- 				s = table[ilin][icol-k].col;
	- 				if (!real(s) || barent(s) || vspen(s) ) 
	+ 				ss = table[ilin][icol-k].col;
	+ 				if (!real(ss) || barent(ss) || vspen(ss) ) 
	  					continue;
	  				Bprint(&tabout, ".nr %d ", TMP);
	  				wide(table[ilin][icol-k].col, FN(ilin, icol - k), SZ(ilin, icol - k));
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t6.c:210,216 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t6.c:213,219
	  			putsize("0");
	  		Bprint(&tabout, "%c", F1);
	  	} else
	- 		Bprint(&tabout, "\\n(%c-", (int)s);
	+ 		Bprint(&tabout, "\\n(%c-", (int)(uintptr)s);
	  }
	  
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 9041 Nov  6 11:11 sys/src/cmd/tbl/t8.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t8.c:9,17 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t8.c:9,17
	  				/* i is line number for deciding format */
	  				/* nl is line number for finding data   usually identical */
	  {
	- 	int	c, lf, ct, form, lwid, vspf, ip, cmidx, exvspen, vforml;
	+ 	int	c, s, lf, ct, form, lwid, vspf, ip, cmidx, exvspen, vforml;
	  	int	vct, chfont, uphalf;
	- 	char	*s, *size, *fn, *rct;
	+ 	char	*ss, *size, *fn, *rct;
	  
	  	cmidx = watchout = vspf = exvspen = 0;
	  	if (i == 0) 
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t8.c:20,39 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t8.c:20,43
	  		fullwide(0,   dboxflg ? '=' : '-');
	  	if (instead[nl] == 0 && fullbot[nl] == 0)
	  		for (c = 0; c < ncol; c++) {
	- 			s = table[nl][c].col;
	- 			if (s == 0) 
	+ 			ss = table[nl][c].col;
	+ 			if (ss == 0) 
	  				continue;
	- 			if (vspen(s)) {
	- 				for (ip = nl; ip < nlin; ip = next(ip))
	- 					if (!vspen(s = table[ip][c].col)) 
	+ 			if (vspen(ss)) {
	+ 				for (ip = nl; ip < nlin; ip = next(ip)){
	+ 					ss = table[ip][c].col;
	+ 					if (!vspen(ss)) 
	  						break;
	- 				if ((int)s > 0 && (int)s < 128)
	- 					Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s);
	+ 				}
	+ 				s = (int)(uintptr)ss;
	+ 				if (s > 0 && s < 128)
	+ 					Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", s);
	  				continue;
	  			}
	- 			if (point(s)) 
	+ 			if (point(ss)) 
	  				continue;
	- 			Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s);
	+ 			s = (int)(uintptr)ss;
	+ 			Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", s);
	  			watchout = 1;
	  		}
	  	if (linestop[nl])
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t8.c:66,86 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t8.c:70,92
	  	vspf = 0;
	  	chfont = 0;
	  	for (c = 0; c < ncol; c++) {
	- 		s = table[nl][c].col;
	- 		if (s == 0) 
	+ 		ss = table[nl][c].col;
	+ 		if (ss == 0) 
	  			continue;
	- 		chfont |= (int)(font[c][stynum[nl]]);
	- 		if (point(s) ) 
	+ 		if(font[c][stynum[nl]])
	+ 			chfont = 1;
	+ 		if (point(ss) ) 
	  			continue;
	+ 		s = (int)(uintptr)ss;
	  		lf = prev(nl);
	  		if (lf >= 0 && vspen(table[lf][c].col))
	  			Bprint(&tabout,
	  			   ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",
	- 			    (int)s, 'a' + c, (int)s, 'a' + c);
	+ 			    s, 'a' + c, s, 'a' + c);
	  		else
	  			Bprint(&tabout,
	  			    ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",
	- 			    (int)s, (int)s);
	+ 			    s, s);
	  	}
	  	if (allflg && once > 0 )
	  		fullwide(i, '-');
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t8.c:117,123 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t8.c:123,129
	  				rct = reg(c, CMID);
	  			Bprint(&tabout, "\\h'|\\n(%2su'", rct);
	  		}
	- 		s = table[nl][c].col;
	+ 		ss = table[nl][c].col;
	  		fn = font[c][stynum[vforml]];
	  		size = csize[c][stynum[vforml]];
	  		if (*size == 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t8.c:150,161 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t8.c:156,167
	  					Bprint(&tabout, "%c%c", F1, F2);
	  					if (uphalf) 
	  						Bprint(&tabout, "\\u");
	- 					puttext(s, fn, size);
	+ 					puttext(ss, fn, size);
	  					if (uphalf) 
	  						Bprint(&tabout, "\\d");
	  					Bprint(&tabout, "%c", F1);
	  				}
	- 				s = table[nl][c].rcol;
	+ 				ss = table[nl][c].rcol;
	  				form = 1;
	  				break;
	  			}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t8.c:179,190 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t8.c:185,196
	  		}
	  		if (realsplit ? rused[c] : used[c]) /*Zero field width*/ {
	  			/* form: 1 left, 2 right, 3 center adjust */
	- 			if (ifline(s)) {
	- 				makeline(i, c, ifline(s));
	+ 			if (ifline(ss)) {
	+ 				makeline(i, c, ifline(ss));
	  				continue;
	  			}
	- 			if (filler(s)) {
	- 				Bprint(&tabout, "\\l'|\\n(%2su\\&%s'", reg(c, CRIGHT), s + 2);
	+ 			if (filler(ss)) {
	+ 				Bprint(&tabout, "\\l'|\\n(%2su\\&%s'", reg(c, CRIGHT), ss + 2);
	  				continue;
	  			}
	  			ip = prev(nl);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t8.c:204,216 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t8.c:210,222
	  			Bprint(&tabout, "%c", F1);
	  			if (form != 1)
	  				Bprint(&tabout, "%c", F2);
	- 			if (vspen(s))
	+ 			if (vspen(ss))
	  				vspf = 1;
	  			else
	  			 {
	  				if (uphalf) 
	  					Bprint(&tabout, "\\u");
	- 				puttext(s, fn, size);
	+ 				puttext(ss, fn, size);
	  				if (uphalf) 
	  					Bprint(&tabout, "\\d");
	  			}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/t8.c:289,295 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/t8.c:295,301
	  			continue;
	  		if (ss == 0) 
	  			continue;
	- 		s = (int)ss;
	+ 		s = (int)(uintptr)ss;
	  		Bprint(&tabout, ".sp |\\n(##u-1v\n");
	  		Bprint(&tabout, ".nr %d ", SIND);
	  		ct = 0;
 [rsc] --rw-rw-r-- M 451989 glenda sys 1274 Nov  6 11:11 sys/src/cmd/tbl/tc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/tbl/tc.c:54,65 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/tbl/tc.c:54,63
	  	return;
	  }
	  
	- 
	  int
	- point(char *s)
	+ point(char *ss)
	  {
	- 	int	ss = (int)s;
	- 	return(ss >= 128 || ss < 0);
	- }
	+ 	int s = (int)(uintptr)ss;
	  
	- 
	+ 	return(s >= 128 || s < 0);
	+ }

Remove unused variable.
 [rsc] --rw-rw-r-- M 451989 glenda sys 6420 Nov  6 11:11 sys/src/cmd/upas/smtp/mxdial.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/upas/smtp/mxdial.c:49,55 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/upas/smtp/mxdial.c:49,55
	  }
	  
	  static int
	- timeout(void *x, char *msg)
	+ timeout(void*, char *msg)
	  {
	  	if(strstr(msg, "alarm"))
	  		return 1;

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 23778 Nov  6 11:07 sys/src/cmd/ar.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:22,28 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:22,28
	  	char	*name;
	  	int	type;
	  	int	len;
	- 	long	offset;
	+ 	vlong	offset;
	  	struct	Arsymref *next;
	  } Arsymref;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:40,46 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:40,46
	  	int	paged;		/* set when some data paged to disk */
	  	char	*fname;		/* paging file name */
	  	int	fd;		/* paging file descriptor */
	- 	long	size;
	+ 	vlong	size;
	  	Armember *head;		/* head of member chain */
	  	Armember *tail;		/* tail of member chain */
	  	Arsymref *sym;		/* head of defined symbol chain */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:118,132 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:118,132
	  int	page(Arfile*);
	  void	pmode(long);
	  void	rl(int);
	- void	scanobj(Biobuf*, Arfile*, int);
	+ void	scanobj(Biobuf*, Arfile*, long);
	  void	select(int*, long);
	  void	setcom(void(*)(char*, int, char**));
	- void	skip(Biobuf*, long);
	+ void	skip(Biobuf*, vlong);
	  int	symcomp(void*, void*);
	  void	trim(char*, char*, int);
	  void	usage(void);
	  void	wrerr(void);
	- void	wrsym(Biobuf*, int, Arsymref*);
	+ void	wrsym(Biobuf*, long, Arsymref*);
	  
	  void	rcmd(char*, int, char**);		/* command processing */
	  void	dcmd(char*, int, char**);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:316,322 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:316,321
	  	Armember *bp;
	  	int fd, i;
	  
	- 
	  	if (!count)
	  		return;
	  	fd = openar(arname, ORDWR, 0);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:517,526 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:516,525
	   *	extract the symbol references from an object file
	   */
	  void
	- scanobj(Biobuf *b, Arfile *ap, int size)
	+ scanobj(Biobuf *b, Arfile *ap, long size)
	  {
	  	int obj;
	- 	long offset;
	+ 	vlong offset;
	  	Dir *d;
	  	static int lastobj = -1;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:634,639 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:633,639
	  	}
	  	return fd;
	  }
	+ 
	  /*
	   *	create an archive and set its header
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:651,656 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:651,657
	  		wrerr();
	  	return fd;
	  }
	+ 
	  /*
	   *		error handling
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:681,686 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:682,688
	  	fprint(2, "usage: ar [%s][%s] archive files ...\n", opt, man);
	  	exits("error");
	  }
	+ 
	  /*
	   *	read the header for the next archive member
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:704,713 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:706,716
	  		;
	  	cp[1] = '\0';
	  	file = name;
	- 	bp->date = atol(bp->hdr.date);
	- 	bp->size = atol(bp->hdr.size);
	+ 	bp->date = strtol(bp->hdr.date, 0, 0);
	+ 	bp->size = strtol(bp->hdr.size, 0, 0);
	  	return bp;
	  }
	+ 
	  /*
	   *	Copy the file referenced by fd to the temp file
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:742,747 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:745,751
	  	}
	  	free(d);
	  }
	+ 
	  /*
	   *	Copy the archive member at the current offset into the temp file.
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:748,754 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:752,758
	  void
	  arcopy(Biobuf *b, Arfile *ap, Armember *bp)
	  {
	- 	int n;
	+ 	long n;
	  
	  	n = bp->size;
	  	if (n & 01)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:759,774 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:763,780
	  		ap->size += n+SAR_HDR;
	  	}
	  }
	+ 
	  /*
	   *	Skip an archive member
	   */
	  void
	- skip(Biobuf *bp, long len)
	+ skip(Biobuf *bp, vlong len)
	  {
	  	if (len & 01)
	  		len++;
	  	Bseek(bp, len, 1);
	  }
	+ 
	  /*
	   *	Stream the three temp files to an archive
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:850,860 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:856,867
	  		Bputc(&b, 0);
	  	Bterm(&b);
	  }
	+ 
	  /*
	   *	Write the defined symbols to the symdef file
	   */
	  void
	- wrsym(Biobuf *bp, int offset, Arsymref *as)
	+ wrsym(Biobuf *bp, long offset, Arsymref *as)
	  {
	  	int off;
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:870,875 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:877,883
	  		as = as->next;
	  	}
	  }
	+ 
	  /*
	   *	Check if the archive member matches an entry on the command line.
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:891,896 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:899,905
	  	}
	  	return 0;
	  }
	+ 
	  /*
	   *	compare the current member to the name of the pivot member
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:920,925 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:929,935
	  	}
	  	return 0;
	  }
	+ 
	  /*
	   *	output a message, if 'v' option was specified
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:930,935 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:940,946
	  	if(vflag)
	  		Bprint(&bout, "%c - %s\n", c, file);
	  }
	+ 
	  /*
	   *	isolate file name by stripping leading directories and trailing slashes
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:951,956 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:962,968
	  		*p = 0;			/* strip trailing slash */
	  	}
	  }
	+ 
	  /*
	   *	utilities for printing long form of 't' command
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:973,979 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:985,991
	  	char *cp;
	  
	  	pmode(strtoul(bp->hdr.mode, 0, 8));
	- 	Bprint(&bout, "%3ld/%1ld", atol(bp->hdr.uid), atol(bp->hdr.gid));
	+ 	Bprint(&bout, "%3ld/%1ld", strtol(bp->hdr.uid, 0, 0), strtol(bp->hdr.gid, 0, 0));
	  	Bprint(&bout, "%7ld", bp->size);
	  	cp = ctime(bp->date);
	  	Bprint(&bout, " %-12.12s %-4.4s ", cp+4, cp+24);
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:1010,1015 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:1022,1028
	  		ap++;
	  	Bputc(&bout, *ap);
	  }
	+ 
	  /*
	   *	Temp file I/O subsystem.  We attempt to cache all three temp files in
	   *	core.  When we run out of memory we spill to disk.
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:1049,1054 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:1062,1068
	  		rderr();
	  	}
	  }
	+ 
	  /*
	   * insert a member buffer into the member chain
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:1062,1067 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:1076,1082
	  		ap->tail->next = bp;
	  	ap->tail = bp;
	  }
	+ 
	  /*
	   *	stream the members in a temp file to the file referenced by 'fd'.
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:1092,1097 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:1107,1113
	  			wrerr();
	  	}
	  }
	+ 
	  /*
	   *	write a member to 'fd'.
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:1109,1114 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:1125,1131
	  		return 0;
	  	return 1;
	  }
	+ 
	  /*
	   *	Spill a member to a disk copy of a temp file
	   */
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:1136,1141 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:1153,1159
	  	free(bp);
	  	return 1;
	  }
	+ 
	  /*
	   *	try to reclaim space by paging.  we try to spill the start, middle,
	   *	and end files, in that order.  there is no particular reason for the
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/ar.c:1166,1171 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/ar.c:1184,1190
	  	}
	  	free(ap);
	  }
	+ 
	  /*
	   *	allocate space for a control block or member buffer.  if the malloc
	   *	fails we try to reclaim space by spilling previously allocated

Add -p flag.
 [rsc] --rw-rw-r-- M 451989 glenda sys 14841 Nov  6 11:29 sys/man/4/factotum
	/n/sourcesdump/2005/1106/plan9/sys/man/4/factotum:4,10 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/4/factotum:4,10
	  .SH SYNOPSIS
	  .B auth/factotum
	  [
	- .B -DdkSun
	+ .B -DdknpuS
	  ] [
	  .B -a asaddr
	  ] [
	/n/sourcesdump/2005/1106/plan9/sys/man/4/factotum:211,216 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/4/factotum:211,224
	  .BR \-S .
	  This option is typically used by
	  the kernel at boot time.
	+ .TP
	+ .B \-p
	+ causes the agent not to mark itself `private'
	+ via 
	+ .IR proc (3),
	+ so that it can be debugged.
	+ It is implied by
	+ .BR \-d .
	  .PD
	  .PP
	  .I Fgui

-
 [rsc] --rw-rw-r-- M 451989 sape sys 1547 Nov  6 11:09 sys/src/games/music/playlistfs/boilerplate.c
	/n/sourcesdump/2005/1106/plan9/sys/src/games/music/playlistfs/boilerplate.c:41,73 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/games/music/playlistfs/boilerplate.c:41,82
	  {
	  	Worker *w;
	  
	- 	if(w = nbrecvp(q))
	- 		send(w->eventc, m);
	- 	return w != nil;
	+ 	while(w = nbrecvp(q)){
	+ 		/* Test for markerdom (see bcastmsg) */
	+ 		if(w->eventc){
	+ 			send(w->eventc, m);
	+ 			return 1;
	+ 		}
	+ 		sendp(q, w);	/* put back */
	+ 	}
	+ 	return 0;
	  }
	  
	  void
	  bcastmsg(Channel *q, Wmsg *m)
	  {
	- 	Worker *w;
	- 	Channel *c;
	+ 	Worker *w, marker;
	  	void *a;
	  
	  	a = m->arg;
	  	/*
	- 	 * Allocate a temp chan to prevent workers from getting the
	- 	 * broadcast and putting themselves back on the workers
	+ 	 * Use a marker to mark the end of the queue.
	+ 	 * This prevents workers from getting the
	+ 	 * broadcast and putting themselves back on the
	  	 * queue before the broadcast has finished
	  	 */
	- 	c = chancreate(sizeof(Worker*), 256);
	- 	while(w = nbrecvp(q))
	- 		sendp(c, w);
	- 	while(w = nbrecvp(c)){
	- 		if(a) m->arg = strdup(a);
	- 		send(w->eventc, m);
	+ 	marker.eventc = nil;
	+ 	sendp(q, &marker);
	+ 	while((w = recvp(q)) != &marker){
	+ 		if(w->eventc == nil){
	+ 			/* somebody else's marker, put it back */
	+ 			sendp(q, w);
	+ 		}else{
	+ 			if(a) m->arg = strdup(a);
	+ 			send(w->eventc, m);
	+ 		}
	  	}
	  	free(a);
	- 	chanfree(c);
	  	m->arg = nil;
	  }
	  

Add debugfactotum, *norealmode, *noe820scan
 [rsc] --rw-rw-r-- M 451989 glenda sys 22077 Nov  6 11:29 sys/man/8/plan9.ini
	/n/sourcesdump/2005/1106/plan9/sys/man/8/plan9.ini:515,520 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/8/plan9.ini:515,526
	  See
	  .IR boot (8)
	  for more.
	+ .SS \fLdebugfactotum=\fP
	+ Causes
	+ .IR boot (8)
	+ to start factotum with the
	+ .B -p
	+ flag, so that it can be debugged.
	  .SS \fLventi=value\fP
	  When booting from a local fossil server backed by a local
	  or remote venti server,
	/n/sourcesdump/2005/1106/plan9/sys/man/8/plan9.ini:551,556 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/8/plan9.ini:557,569
	  consults only the first table,
	  .B old
	  only the second.
	+ .SS \fL*norealmode=\fP
	+ The kernel switches the processor to 16-bit real mode 
	+ to run BIOS interrupts, for example to find the memory map or to enable VESA. 
	+ This variable disables such switches.
	+ .SS \fL*noe820scan=\fP
	+ When available, the kernel uses the BIOS E820 memory map
	+ to size memory.  This variable disables the scan.
	  .SS \fL*maxmem=value\fP
	  This defines the maximum physical address that the system will scan when sizing memory.
	  By default the operating system will scan up to 768 megabytes, but setting
	/n/sourcesdump/2005/1106/plan9/sys/man/8/plan9.ini:561,566 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/8/plan9.ini:574,580
	  for the kernel to find it.
	  .B *maxmem
	  must be less than 1.75 gigabytes.
	+ This variable is not consulted if using the E820 memory map.
	  .SS \fL*kernelpercent=value\fP
	  This defines what percentage of available memory is reserved for the kernel allocation pool.
	  The remainder is left for user processes.  The default

64-bit fixes.
 [rsc] --rw-rw-r-- M 451989 glenda sys 275 Nov  6 11:14 sys/src/cmd/9nfs/listalloc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/9nfs/listalloc.c:6,18 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/9nfs/listalloc.c:6,17
	  void *
	  listalloc(long n, long size)
	  {
	- 	ulong *p, *base;
	+ 	char *p, *base;
	  
	- 	size += sizeof(ulong) - 1;
	- 	size /= sizeof(ulong);
	- 	p = base = malloc(n*size*sizeof(ulong));
	+ 	size = (size+sizeof(ulong)-1)/sizeof(ulong);
	+ 	p = base = malloc(n*size);
	  	while(--n > 0){
	- 		*p = (ulong)(p+size);
	+ 		*(char**)p = p+size;
	  		p += size;
	  	}
	  	*p = 0;
 [rsc] --rw-rw-r-- M 451989 glenda sys 9526 Nov  6 11:14 sys/src/cmd/9nfs/nfs.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/9nfs/nfs.c:387,393 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/9nfs/nfs.c:387,393
	  		dataptr[2+n] = 0;
	  	}else{
	  		PLONG(starttime);
	- 		PLONG(xp->s);
	+ 		PLONG((u32int)(uintptr)xp->s);
	  		x = xp->qid.path;
	  		PLONG(x);
	  		x = xp->qid.path>>32;
 [rsc] --rw-rw-r-- M 451989 glenda sys 1894 Nov  6 11:14 sys/src/cmd/9nfs/xfile.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/9nfs/xfile.c:14,25 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/9nfs/xfile.c:14,26
	  	int k;
	  	Xfile **hp, *f, *pf;
	  
	- 	k = ((ulong)qid->path ^ (((ulong)s)<<24))%FIDMOD;
	+ 	k = ((ulong)qid->path ^ (((u32int)(uintptr)s)<<24))%FIDMOD;
	  	hp = &xfiles[k];
	  
	  	lock(&xlocks[k]);
	  	for(f=*hp, pf=0; f; pf=f, f=f->next)
	- 		if(f->qid.path == qid->path && f->s == s)
	+ 		if(f->qid.path == qid->path 
	+ 		&& (u32int)(uintptr)f->s == (u32int)(uintptr)s)
	  			break;
	  	if(f && pf){
	  		pf->next = f->next;

Describe /dev/vgabios.
 [rsc] --rw-rw-r-- M 451989 glenda sys 4957 Nov  6 13:16 sys/man/3/vga
	/n/sourcesdump/2005/1106/plan9/sys/man/3/vga:5,15 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/3/vga:5,14
	  .nf
	  .B bind #v /dev
	  
	+ .B /dev/vgabios
	  .B /dev/vgactl
	- 
	- .B /dev/vgaovlctl
	- 
	  .B /dev/vgaovl
	+ .B /dev/vgaovlctl
	  .fi
	  .SH DESCRIPTION
	  The VGA device allows configuration of a graphics controller
	/n/sourcesdump/2005/1106/plan9/sys/man/3/vga:23,28 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/3/vga:22,31
	  it is used to implement configuration and setup of VGA controller cards.
	  This is usually performed by
	  .IR vga (8).
	+ .PP
	+ .B Vgabios
	+ provides read-only access to the low 640kB of memory,
	+ where the VGA and other BIOS ROMs are located.
	  .PP
	  Writing strings to 
	  .B vgactl
 [rsc] --rw-rw-r-- M 451989 glenda sys 3864 Nov  6 13:16 sys/man/8/vga
	/n/sourcesdump/2005/1106/plan9/sys/man/8/vga:59,65 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/8/vga:59,64
	  .TP
	  .B -c
	  disable the use of the hardware graphics cursor.
	- (Since there is no software cursor, this disables the cursor entirely.)
	  .TP
	  .B -d
	  include the color palette in whatever actions are performed,

Rebuild.
 [rsc] --rwxrwxr-x M 451989 glenda sys 216948 Nov  6 17:48 386/9load
 [rsc] --rwxrwxr-x M 451989 glenda sys 311884 Nov  6 17:48 386/9loaddebug
 [rsc] --rwxrwxr-x M 451989 glenda sys 135668 Nov  6 17:48 386/9loadlite
 [rsc] --rwxrwxr-x M 451989 glenda sys 200131 Nov  6 17:48 386/9loadlitedebug
 [rsc] --rwxrwxr-x M 451989 presotto sys 216948 Nov  6 17:48 386/9pxeload
 [rsc] --rwxrwxr-x M 451989 glenda sys 101212 Nov  6 17:48 386/init
 [rsc] --rwxrwxr-x M 451989 glenda sys 72524 Nov  6 17:49 386/ld.com
 [rsc] --rwxrwxr-x M 451989 glenda sys 407 Nov  6 17:48 386/mbr
 [rsc] --rwxrwxr-x M 451989 glenda sys 494 Nov  6 17:48 386/pbs
 [rsc] --rwxrwxr-x M 451989 glenda sys 507 Nov  6 17:49 386/pbslba

Fix examples.
 [rsc] --rw-rw-r-- M 451989 rsc sys 1251 Nov  6 17:57 sys/man/8/statusbar
	/n/sourcesdump/2005/1106/plan9/sys/man/8/statusbar:46,60 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/8/statusbar:46,63
	  .PD
	  .SH EXAMPLE
	  The
	- .B -d
	- options to
	- .IR hget(1),
	- .IR venti/fmtarenas ,
	- and
	- .I venti/fmtisect
	- (see
	- .IR ventiaux (8))
	- cause them to print status lines suitable for
	+ .B -v
	+ option to
	+ .IR hget(1)
	+ .\" and the 
	+ .\" .B -d
	+ .\" option to
	+ .\" .IR venti/fmtarenas
	+ .\" and
	+ .\" .I venti/fmtisect
	+ .\" (see
	+ ,\" .IR ventiaux (8))
	+ causes it to print status lines suitable for
	  input to
	  .IR statusbar .
	  .PP
	/n/sourcesdump/2005/1106/plan9/sys/man/8/statusbar:61,67 - 
	/n/sourcesdump/2005/1107/plan9/sys/man/8/statusbar:64,70
	  Monitor a long download:
	  .IP
	  .EX
	- hget -d -o bigfile http://server.com/bigfile | 
	+ hget -v -o bigfile http://server.com/bigfile | 
	    aux/statusbar 'big file download'
	  .EE
	  .SH SOURCE


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.