printk("sonic_init: initialize receive descriptors\n"); for (i = 0; i < SONIC_NUM_RDS; i++) { lp->rda[i].rx_status = 0; lp->rda[i].rx_pktlen = 0; lp->rda[i].rx_pktptr_l = 0; lp->rda[i].rx_pktptr_h = 0; lp->rda[i].rx_seqno = 0; lp->rda[i].in_use = 1; lp->rda[i].link = lp->rda_laddr + (i + 1) * sizeof(sonic_rd_t); 
printk("sonic_init: initialize receive descriptors\n"); for (i=0; i<SONIC_NUM_RDS; i++) { sonic_rda_put(dev, i, SONIC_RD_STATUS, 0); sonic_rda_put(dev, i, SONIC_RD_PKTLEN, 0); sonic_rda_put(dev, i, SONIC_RD_PKTPTR_L, 0); sonic_rda_put(dev, i, SONIC_RD_PKTPTR_H, 0); sonic_rda_put(dev, i, SONIC_RD_SEQNO, 0); sonic_rda_put(dev, i, SONIC_RD_IN_USE, 1); sonic_rda_put(dev, i, SONIC_RD_LINK, lp->rda_laddr + ((i+1) * SIZEOF_SONIC_RD * SONIC_BUS_SCALE(lp->dma_bitmode))); 
static int sonic_init(struct net_device *dev){	unsigned int base_addr = dev->base_addr;	unsigned int cmd;	struct sonic_local *lp = (struct sonic_local *) dev->priv;	unsigned int rra_start;	unsigned int rra_end;	int i;	/*	 * put the Sonic into software-reset mode and	 * disable all interrupts	 */	SONIC_WRITE(SONIC_ISR, 0x7fff);	SONIC_WRITE(SONIC_IMR, 0);	SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);	/*	 * clear software reset flag, disable receiver, clear and	 * enable interrupts, then completely initialize the SONIC	 */	SONIC_WRITE(SONIC_CMD, 0);	SONIC_WRITE(SONIC_CMD, SONIC_CR_RXDIS);	/*	 * initialize the receive resource area	 */	if (sonic_debug > 2)		printk("sonic_init: initialize receive resource area\n");	rra_start = lp->rra_laddr & 0xffff;	rra_end =	    (rra_start + (SONIC_NUM_RRS * sizeof(sonic_rr_t))) & 0xffff;	for (i = 0; i < SONIC_NUM_RRS; i++) {		lp->rra[i].rx_bufadr_l =		    (lp->rba_laddr + i * SONIC_RBSIZE) & 0xffff;		lp->rra[i].rx_bufadr_h =		    (lp->rba_laddr + i * SONIC_RBSIZE) >> 16;		lp->rra[i].rx_bufsize_l = SONIC_RBSIZE >> 1;		lp->rra[i].rx_bufsize_h = 0;	}	/* initialize all RRA registers */	SONIC_WRITE(SONIC_RSA, rra_start);	SONIC_WRITE(SONIC_REA, rra_end);	SONIC_WRITE(SONIC_RRP, rra_start);	SONIC_WRITE(SONIC_RWP, rra_end);	SONIC_WRITE(SONIC_URRA, lp->rra_laddr >> 16);	SONIC_WRITE(SONIC_EOBC, (SONIC_RBSIZE - 2) >> 1);	lp->cur_rra =	    lp->rra_laddr + (SONIC_NUM_RRS - 1) * sizeof(sonic_rr_t);	/* load the resource pointers */	if (sonic_debug > 3)		printk("sonic_init: issueing RRRA command\n");	SONIC_WRITE(SONIC_CMD, SONIC_CR_RRRA);	i = 0;	while (i++ < 100) {		if (SONIC_READ(SONIC_CMD) & SONIC_CR_RRRA)			break;	}	if (sonic_debug > 2)		printk("sonic_init: status=%x\n", SONIC_READ(SONIC_CMD));	/*	 * Initialize the receive descriptors so that they	 * become a circular linked list, ie. let the last	 * descriptor point to the first again.	 */	if (sonic_debug > 2)		printk("sonic_init: initialize receive descriptors\n");	for (i = 0; i < SONIC_NUM_RDS; i++) {		lp->rda[i].rx_status = 0;		lp->rda[i].rx_pktlen = 0;		lp->rda[i].rx_pktptr_l = 0;		lp->rda[i].rx_pktptr_h = 0;		lp->rda[i].rx_seqno = 0;		lp->rda[i].in_use = 1;		lp->rda[i].link =		    lp->rda_laddr + (i + 1) * sizeof(sonic_rd_t);	}	/* fix last descriptor */	lp->rda[SONIC_NUM_RDS - 1].link = lp->rda_laddr;	lp->cur_rx = 0;	SONIC_WRITE(SONIC_URDA, lp->rda_laddr >> 16);	SONIC_WRITE(SONIC_CRDA, lp->rda_laddr & 0xffff);	/* 	 * initialize transmit descriptors	 */	if (sonic_debug > 2)		printk("sonic_init: initialize transmit descriptors\n");	for (i = 0; i < SONIC_NUM_TDS; i++) {		lp->tda[i].tx_status = 0;		lp->tda[i].tx_config = 0;		lp->tda[i].tx_pktsize = 0;		lp->tda[i].tx_frag_count = 0;		lp->tda[i].link =		    (lp->tda_laddr +		     (i + 1) * sizeof(sonic_td_t)) | SONIC_END_OF_LINKS;	}	lp->tda[SONIC_NUM_TDS - 1].link =	    (lp->tda_laddr & 0xffff) | SONIC_END_OF_LINKS;	SONIC_WRITE(SONIC_UTDA, lp->tda_laddr >> 16);	SONIC_WRITE(SONIC_CTDA, lp->tda_laddr & 0xffff);	lp->cur_tx = lp->dirty_tx = 0;	/*	 * put our own address to CAM desc[0]	 */	lp->cda.cam_desc[0].cam_cap0 =	    dev->dev_addr[1] << 8 | dev->dev_addr[0];	lp->cda.cam_desc[0].cam_cap1 =	    dev->dev_addr[3] << 8 | dev->dev_addr[2];	lp->cda.cam_desc[0].cam_cap2 =	    dev->dev_addr[5] << 8 | dev->dev_addr[4];	lp->cda.cam_enable = 1;	for (i = 0; i < 16; i++)		lp->cda.cam_desc[i].cam_entry_pointer = i;	/*	 * initialize CAM registers	 */	SONIC_WRITE(SONIC_CDP, lp->cda_laddr & 0xffff);	SONIC_WRITE(SONIC_CDC, 16);	/*	 * load the CAM	 */	SONIC_WRITE(SONIC_CMD, SONIC_CR_LCAM);	i = 0;	while (i++ < 100) {		if (SONIC_READ(SONIC_ISR) & SONIC_INT_LCD)			break;	}	if (sonic_debug > 2) {		printk("sonic_init: CMD=%x, ISR=%x\n",		       SONIC_READ(SONIC_CMD), SONIC_READ(SONIC_ISR));	}	/*	 * enable receiver, disable loopback	 * and enable all interrupts	 */	SONIC_WRITE(SONIC_CMD, SONIC_CR_RXEN | SONIC_CR_STP);	SONIC_WRITE(SONIC_RCR, SONIC_RCR_DEFAULT);	SONIC_WRITE(SONIC_TCR, SONIC_TCR_DEFAULT);	SONIC_WRITE(SONIC_ISR, 0x7fff);	SONIC_WRITE(SONIC_IMR, SONIC_IMR_DEFAULT);	cmd = SONIC_READ(SONIC_CMD);	if ((cmd & SONIC_CR_RXEN) == 0 || (cmd & SONIC_CR_STP) == 0)		printk("sonic_init: failed, status=%x\n", cmd);	if (sonic_debug > 2)		printk("sonic_init: new status=%x\n",		       SONIC_READ(SONIC_CMD));	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/efcce839360fb3a7b6dedeacaec80f68b0f2d052/sonic.c/buggy/drivers/net/sonic.c