kernels/linux-2.4.0/drivers/net/tokenring/tms380tr.c
/*
 * Copy initialisation data to adapter memory, beginning at address
 * 1:0A00; Starting DMA test and evaluating result bits.
 */
Copy initialisation data to adapter memory, beginning at address
1:0A00; Starting DMA test and evaluating result bits.
Copy initialisation data to adapter memory beginning at address 1 : 0A00 ; Starting DMA test and evaluating result bits .
static int tms380tr_init_adapter(struct net_device *dev)
{
	struct net_local *tp = (struct net_local *)dev->priv;
	const unsigned char SCB_Test[6] = {0x00, 0x00, 0xC1, 0xE2, 0xD4, 0x8B};
	const unsigned char SSB_Test[8] = {0xFF, 0xFF, 0xD1, 0xD7,
						0xC5, 0xD9, 0xC3, 0xD4};
	void *ptr = (void *)&tp->ipb;
	unsigned short *ipb_ptr = (unsigned short *)ptr;
	unsigned char *cb_ptr = (unsigned char *) &tp->scb;
	unsigned char *sb_ptr = (unsigned char *) &tp->ssb;
	unsigned short Status;
	int i, loop_cnt, retry_cnt;
	tp->ipb.SCB_Addr = SWAPW(virt_to_bus(&tp->scb));
	tp->ipb.SSB_Addr = SWAPW(virt_to_bus(&tp->ssb));
	retry_cnt = INIT_MAX_RETRIES;
	do {
		retry_cnt--;
		SIFWRITEW(0x0001, SIFADX);
		SIFWRITEW(0x0A00, SIFADD);
		for(i = 0; i < 11; i++)
			SIFWRITEW(ipb_ptr[i], SIFINC);
		tms380tr_exec_sifcmd(dev, CMD_EXECUTE);
		loop_cnt = INIT_MAX_LOOPCNT;	
		do {
			Status = 0;
			loop_cnt--;
			tms380tr_wait(HALF_SECOND);
			Status = SIFREADW(SIFSTS);
			Status &= STS_MASK;
		} while(((Status &(STS_INITIALIZE | STS_ERROR | STS_TEST)) != 0)
			&& ((Status & STS_ERROR) == 0) && (loop_cnt != 0));
		if((Status & (STS_INITIALIZE | STS_ERROR | STS_TEST)) == 0)
		{
			i = 0;
			do {	
				if(SCB_Test[i] != *(cb_ptr + i))
					return (-1);
				i++;
			} while(i < 6);
			i = 0;
			do {	
				if(SSB_Test[i] != *(sb_ptr + i))
					return (-1);
				i++;
			} while (i < 8);
			return (1);	
		}
		else
		{
			if((Status & STS_ERROR) != 0)
			{
				Status = SIFREADW(SIFSTS);
				Status &= STS_ERROR_MASK;
				return (-1); 
			}
			else
			{
				if(retry_cnt > 0)
				{
					tms380tr_exec_sifcmd(dev, EXEC_SOFT_RESET);
					tms380tr_wait(HALF_SECOND);
				}
			}
		}
	} while(retry_cnt > 0);
	return (-1);
}
static int tms380tr_init_adapter ( struct net_device * dev ) { struct net_local * tp = ( struct net_local * ) dev -> priv ; const unsigned char SCB_Test [ 6 ] = { 0x00 , 0x00 , 0xC1 , 0xE2 , 0xD4 , 0x8B } ; const unsigned char SSB_Test [ 8 ] = { 0xFF , 0xFF , 0xD1 , 0xD7 , 0xC5 , 0xD9 , 0xC3 , 0xD4 } ; void * ptr = ( void * ) & tp -> ipb ; unsigned short * ipb_ptr = ( unsigned short * ) ptr ; unsigned char * cb_ptr = ( unsigned char * ) & tp -> scb ; unsigned char * sb_ptr = ( unsigned char * ) & tp -> ssb ; unsigned short Status ; int i , loop_cnt , retry_cnt ; tp -> ipb . SCB_Addr = SWAPW ( virt_to_bus ( & tp -> scb ) ) ; tp -> ipb . SSB_Addr = SWAPW ( virt_to_bus ( & tp -> ssb ) ) ; retry_cnt = INIT_MAX_RETRIES ; do { retry_cnt -- ; SIFWRITEW ( 0x0001 , SIFADX ) ; SIFWRITEW ( 0x0A00 , SIFADD ) ; for ( i = 0 ; i < 11 ; i ++ ) SIFWRITEW ( ipb_ptr [ i ] , SIFINC ) ; tms380tr_exec_sifcmd ( dev , CMD_EXECUTE ) ; loop_cnt = INIT_MAX_LOOPCNT ; do { Status = 0 ; loop_cnt -- ; tms380tr_wait ( HALF_SECOND ) ; Status = SIFREADW ( SIFSTS ) ; Status &= STS_MASK ; } while ( ( ( Status & ( STS_INITIALIZE | STS_ERROR | STS_TEST ) ) != 0 ) && ( ( Status & STS_ERROR ) == 0 ) && ( loop_cnt != 0 ) ) ; if ( ( Status & ( STS_INITIALIZE | STS_ERROR | STS_TEST ) ) == 0 ) { i = 0 ; do { if ( SCB_Test [ i ] != * ( cb_ptr + i ) ) return ( -1 ) ; i ++ ; } while ( i < 6 ) ; i = 0 ; do { if ( SSB_Test [ i ] != * ( sb_ptr + i ) ) return ( -1 ) ; i ++ ; } while ( i < 8 ) ; return ( 1 ) ; } else { if ( ( Status & STS_ERROR ) != 0 ) { Status = SIFREADW ( SIFSTS ) ; Status &= STS_ERROR_MASK ; return ( -1 ) ; } else { if ( retry_cnt > 0 ) { tms380tr_exec_sifcmd ( dev , EXEC_SOFT_RESET ) ; tms380tr_wait ( HALF_SECOND ) ; } } } } while ( retry_cnt > 0 ) ; return ( -1 ) ; }
Copy initialisation data to adapter memory, beginning at address
 1:0A00; Starting DMA test and evaluating result bits.
Copy initialisation data to adapter memory beginning at address 1 : 0A00 ; Starting DMA test and evaluating result bits .
/* Normalize: byte order low/high, word order high/low! (only IPB!) */ /* Maximum: three initialization retries */ /* Transfer initialization block */ /* To address 0001:0A00 of adapter RAM */ /* Write 11 words to adapter RAM */ /* Execute SCB adapter command */ /* Maximum: 11 seconds */ /* While remaining retries, no error and not completed */ /* Mask interesting status bits */ /* Initialization completed without error */ /* Test if contents of SCB is valid */ /* DMA data error: wrong data in SCB */ /* Test if contents of SSB is valid */ /* DMA data error: wrong data in SSB */ /* Adapter successfully initialized */ /* Initialization error occurred */ /* ShowInitialisationErrorCode(Status); */ /* Unrecoverable error */ /* Reset adapter and try init again */