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

1996/0210/pc/devata.c (diff list | history)

1996/0112/sys/src/9/pc/devata.c:49,541996/0210/sys/src/9/pc/devata.c:49,58 (short | long | prev | next)
1995/0213    
	 Serr=		 (1<<0), 
	Pcmd=		7,	/* cmd port (write) */ 
 
1996/0210    
	Pctrl=		0x206,	/* device control, alternate status */ 
	 nIEN=		(1<<1), 
	 Srst=		(1<<2), 
 
1995/0213    
	/* commands */ 
1995/1206    
	Cfirst=		0xFF,	/* pseudo command for initialisation */ 
1995/0213    
	Cread=		0x20, 
1996/0112/sys/src/9/pc/devata.c:152,1581996/0210/sys/src/9/pc/devata.c:156,162
1995/0213    
 
	int	pbase;		/* base port */ 
1995/1206    
	uchar	ctlrno; 
	uchar	noatapi; 
1996/0210    
	uchar	resetok; 
1995/0213    
 
	/* 
	 *  current operation 
1996/0112/sys/src/9/pc/devata.c:354,3601996/0210/sys/src/9/pc/devata.c:358,364
1995/1206    
{ 
	Controller *ctlr; 
	int atapi, mask, port; 
	uchar error, status; 
1996/0210    
	uchar error, status, msb, lsb; 
1995/1206    
 
	/* 
	 * Check the existence of a controller by verifying a sensible 
1996/0112/sys/src/9/pc/devata.c:377,3881996/0210/sys/src/9/pc/devata.c:381,393
1995/1206    
	ctlr->ctlrno = ctlrno; 
	ctlr->lastcmd = 0xFF; 
 
1996/0210    
 
1995/1206    
	/* 
	 * Attempt to check the existence of drives on the controller 
	 * by issuing a 'check device diagnostics' command. 
	 * Issuing a device reset here would possibly destroy any BIOS 
	 * drive remapping and, anyway, some controllers (Vibra16) don't 
	 * seem to implement the control-block registers. 
1996/0210    
	 * seem to implement the control-block registers; do it if requested. 
1995/1206    
	 * Unfortunately the vector must be set at this point as the Cedd 
	 * command will generate an interrupt, which means the ataintr routine 
	 * will be left on the interrupt call chain even if there are no 
1996/0112/sys/src/9/pc/devata.c:392,3971996/0210/sys/src/9/pc/devata.c:397,413
1995/1206    
	 * ATAPI signature straight off. If we find it there will be no probe 
	 * done for a slave. Tough. 
	 */ 
1996/0210    
	if(ctlr->resetok){ 
		outb(port+Pctrl, Srst|nIEN); 
		microdelay(1); 
		outb(port+Pctrl, 0); 
		if(atactlrwait(ctlr, DHmagic, 0, 100)){ 
			DPRINT("ata%d: Srst status %ux/%ux/%ux\n", ctlrno, 
				inb(port+Pstatus), inb(port+Pcylmsb), inb(port+Pcyllsb)); 
			xfree(ctlr); 
		} 
	} 
 
1995/1206    
	atapi = 0; 
	mask = 0; 
	status = inb(port+Pstatus); 
1996/0112/sys/src/9/pc/devata.c:405,4121996/0210/sys/src/9/pc/devata.c:421,428
1995/1206    
		goto skipedd; 
	} 
	if(atactlrwait(ctlr, DHmagic, 0, MS2TK(1)) || waserror()){ 
1995/1208    
		DPRINT("ata%d: Cedd status %ux/%ux/%ux\n", 
			ctlrno, inb(port+Pstatus), inb(port+Pcylmsb), inb(port+Pcyllsb)); 
1996/0210    
		DPRINT("ata%d: Cedd status %ux/%ux/%ux\n", ctlrno, 
			inb(port+Pstatus), inb(port+Pcylmsb), inb(port+Pcyllsb)); 
1995/1206    
		xfree(ctlr); 
		return -1; 
	} 
1996/0112/sys/src/9/pc/devata.c:447,4551996/0210/sys/src/9/pc/devata.c:463,477
1995/1206    
	DPRINT("ata%d: slave diag status %ux, error %ux\n", ctlr->ctlrno, status, error); 
	if(status && (status & (Sbusy|Serr)) == 0 && (error & ~0x80) == 0x01) 
		mask |= 0x02; 
	else if(status == 0 && inb(port+Pcylmsb) == 0xEB && inb(port+Pcyllsb) == 0x14){ 
		atapi |= 0x02; 
		mask |= 0x02; 
1996/0210    
	else if(status == 0){ 
		msb = inb(port+Pcylmsb); 
		lsb = inb(port+Pcyllsb); 
		DPRINT("ata%d: ATAPI slave %uX %uX %uX\n", ctlrno, status, 
			inb(port+Pcylmsb), inb(port+Pcyllsb)); 
		if(msb == 0xEB && lsb == 0x14){ 
			atapi |= 0x02; 
			mask |= 0x02; 
		} 
1995/1206    
	} 
 
skipedd: 
1996/0112/sys/src/9/pc/devata.c:514,5211996/0210/sys/src/9/pc/devata.c:536,543
1995/1206    
				DPRINT("ata%d: opt spindownmask %ux\n", 
					ctlrno, spindownmask); 
			} 
			else if(strcmp(isa.opt[i], "noatapi") == 0) 
				atactlr[ctlrno]->noatapi = 1; 
1996/0210    
			else if(strcmp(isa.opt[i], "reset") == 0) 
				atactlr[ctlrno]->resetok = 1; 
1995/1206    
		} 
	} 
1995/0213    
} 
1996/0112/sys/src/9/pc/devata.c:1091,10971996/0210/sys/src/9/pc/devata.c:1113,1122
1995/1206    
	IUNLOCK(&cp->reglock); 
1995/0213    
 
1995/1208    
	DPRINT("%s: ident command %ux sent\n", dp->vol, cmd); 
1995/1209    
	atasleep(cp, 1000); 
1996/0210    
	if(cmd == Cident) 
		atasleep(cp, 3000); 
	else 
		atasleep(cp, 30000); 
1995/0818    
 
1995/0213    
	if(cp->status & Serr){ 
1995/1206    
		DPRINT("%s: bad disk ident status\n", dp->vol); 


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