plan 9 kernel history: overview | file list | diff list

1991/1005/pc/devfloppy.c (diff list | history)

1991/1005/sys/src/9/pc/devfloppy.c:175,1801991/1006/sys/src/9/pc/devfloppy.c:175,181 (short | long | prev | next)
1991/0924    
static int	floppysense(void); 
static void	floppywait(void); 
1991/0802    
static long	floppyxfer(Drive*, int, void*, long, long); 
1991/1006    
static long	floppythrice(Drive*, int, void*, long, long); 
1991/0924    
static int	cmddone(void*); 
void Xdelay(int); 
1991/0731    
 
1991/1005/sys/src/9/pc/devfloppy.c:387,3931991/1006/sys/src/9/pc/devfloppy.c:388,394
1991/0809    
			 */ 
1991/0924    
			if(dp->ccyl!=cyl || dp->chead!=head){ 
1991/0809    
				dp->ccyl = -1; 
1991/0924    
				i = floppyxfer(dp, Fread, dp->cache, 
1991/1006    
				i = floppythrice(dp, Fread, dp->cache, 
1991/0924    
					(cyl*dp->t->heads+head)*nn, nn); 
				if(i != nn){ 
					if(i == 0) 
1991/1005/sys/src/9/pc/devfloppy.c:420,4261991/1006/sys/src/9/pc/devfloppy.c:421,426
1991/0731    
	long rv, i; 
1991/0924    
	char *aa = a; 
	int dev; 
1991/0927    
extern void vgaset(char*); 
1991/0731    
 
1991/0802    
	rv = 0; 
1991/0924    
	dp = &fl.d[c->qid.path & ~Qmask]; 
1991/1005/sys/src/9/pc/devfloppy.c:438,4471991/1006/sys/src/9/pc/devfloppy.c:438,449
1991/0924    
			floppypos(dp, c->offset+rv); 
			if(dp->tcyl == dp->ccyl) 
				dp->ccyl = -1; 
			i = floppyxfer(dp, Fwrite, aa+rv, c->offset+rv, 
1991/1006    
			i = floppythrice(dp, Fwrite, aa+rv, c->offset+rv, 
1991/0924    
				n-rv); 
1991/0802    
			if(i <= 0) 
1991/1006    
			if(i < 0) 
1991/0802    
				break; 
1991/1006    
			if(i == 0) 
				error(Eio); 
1991/0802    
		} 
1991/0925    
		qunlock(&fl); 
		poperror(); 
1991/1005/sys/src/9/pc/devfloppy.c:453,4601991/1006/sys/src/9/pc/devfloppy.c:455,460
1991/0924    
		} else if(SNCMP(aa, "reset") == 0){ 
1991/0925    
			fl.confused = 1; 
1991/0924    
			floppyon(dp); 
1991/0927    
		} else if(SNCMP(aa, "v") == 0){ 
			vgaset(aa+1); 
1991/0924    
		} 
1991/0925    
		qunlock(&fl); 
1991/0924    
		break; 
1991/1005/sys/src/9/pc/devfloppy.c:755,7611991/1006/sys/src/9/pc/devfloppy.c:755,782
1991/0802    
	return dp->cyl; 
1991/0727    
} 
 
1991/1006    
/* 
 *  since floppies are so flakey, try 3 times before giving up 
 */ 
1991/0731    
static long 
1991/1006    
floppythrice(Drive *dp, int cmd, void *a, long off, long n) 
{ 
	int tries; 
	long rv; 
 
	for(tries = 0; ; tries++){ 
		if(waserror()){ 
			if(strcmp(u->error, errstrtab[Eintr])==0 || tries > 3) 
				nexterror(); 
		} else { 
			rv = floppyxfer(dp, cmd, a, off, n); 
			poperror(); 
			return rv; 
		} 
	} 
} 
 
static long 
1991/0802    
floppyxfer(Drive *dp, int cmd, void *a, long off, long n) 
1991/0727    
{ 
	long offset; 
1991/1005/sys/src/9/pc/devfloppy.c:830,8371991/1006/sys/src/9/pc/devfloppy.c:851,856
1991/0924    
	offset = offset*dp->t->sectors + fl.stat[5] - 1; 
	offset = offset * c2b[fl.stat[6]]; 
1991/0802    
	if(offset != off+dp->len){ 
1991/0924    
		print("new offset %d instead of %d\n", offset, off+dp->len); 
1991/0925    
		print("	%d %d %d\n", fl.stat[3], fl.stat[4], fl.stat[5]); 
1991/0727    
		dp->confused = 1; 
1991/0731    
		errors("floppy drive lost"); 
1991/0727    
	} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)