PHYSADDR(dev->mem_start) << 3); 
CPHYSADDR(dev->mem_start) << 3); 
static int __init dec_lance_init(const int type, const int slot){	static unsigned version_printed;	static const char fmt[] = "declance%d";	char name[10];	struct net_device *dev;	struct lance_private *lp;	volatile struct lance_regs *ll;	int i, ret;	unsigned long esar_base;	unsigned char *esar;#ifndef CONFIG_TC	system_base = KN01_LANCE_BASE;#endif	if (dec_lance_debug && version_printed++ == 0)		printk(version);	i = 0;	dev = root_lance_dev;	while (dev) {		i++;		lp = (struct lance_private *)dev->priv;		dev = lp->next;	}	snprintf(name, sizeof(name), fmt, i);	dev = alloc_etherdev(sizeof(struct lance_private));	if (!dev) {		printk(KERN_ERR "%s: Unable to allocate etherdev, aborting.\n",			name);		ret = -ENOMEM;		goto err_out;	}	/*	 * alloc_etherdev ensures the data structures used by the LANCE	 * are aligned.	 */	lp = netdev_priv(dev);	spin_lock_init(&lp->lock);	lp->type = type;	lp->slot = slot;	switch (type) {#ifdef CONFIG_TC	case ASIC_LANCE:		dev->base_addr = system_base + IOASIC_LANCE;		/* buffer space for the on-board LANCE shared memory */		/*		 * FIXME: ugly hack!		 */		dev->mem_start = KSEG1ADDR(0x00020000);		dev->mem_end = dev->mem_start + 0x00020000;		dev->irq = dec_interrupt[DEC_IRQ_LANCE];		esar_base = system_base + IOASIC_ESAR;		/* Workaround crash with booting KN04 2.1k from Disk */		memset((void *)dev->mem_start, 0,		       dev->mem_end - dev->mem_start);		/*		 * setup the pointer arrays, this sucks [tm] :-(		 */		for (i = 0; i < RX_RING_SIZE; i++) {			lp->rx_buf_ptr_cpu[i] =				(char *)(dev->mem_start + BUF_OFFSET_CPU +					 2 * i * RX_BUFF_SIZE);			lp->rx_buf_ptr_lnc[i] =				(char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE);		}		for (i = 0; i < TX_RING_SIZE; i++) {			lp->tx_buf_ptr_cpu[i] =				(char *)(dev->mem_start + BUF_OFFSET_CPU +					 2 * RX_RING_SIZE * RX_BUFF_SIZE +					 2 * i * TX_BUFF_SIZE);			lp->tx_buf_ptr_lnc[i] =				(char *)(BUF_OFFSET_LNC +					 RX_RING_SIZE * RX_BUFF_SIZE +					 i * TX_BUFF_SIZE);		}		/* Setup I/O ASIC LANCE DMA.  */		lp->dma_irq = dec_interrupt[DEC_IRQ_LANCE_MERR];		ioasic_write(IO_REG_LANCE_DMA_P,			     PHYSADDR(dev->mem_start) << 3);		break;	case PMAD_LANCE:		claim_tc_card(slot);		dev->mem_start = get_tc_base_addr(slot);		dev->base_addr = dev->mem_start + 0x100000;		dev->irq = get_tc_irq_nr(slot);		esar_base = dev->mem_start + 0x1c0002;		lp->dma_irq = -1;		for (i = 0; i < RX_RING_SIZE; i++) {			lp->rx_buf_ptr_cpu[i] =				(char *)(dev->mem_start + BUF_OFFSET_CPU +					 i * RX_BUFF_SIZE);			lp->rx_buf_ptr_lnc[i] =				(char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE);		}		for (i = 0; i < TX_RING_SIZE; i++) {			lp->tx_buf_ptr_cpu[i] =				(char *)(dev->mem_start + BUF_OFFSET_CPU +					 RX_RING_SIZE * RX_BUFF_SIZE +					 i * TX_BUFF_SIZE);			lp->tx_buf_ptr_lnc[i] =				(char *)(BUF_OFFSET_LNC +					 RX_RING_SIZE * RX_BUFF_SIZE +					 i * TX_BUFF_SIZE);		}		break;#endif	case PMAX_LANCE:		dev->irq = dec_interrupt[DEC_IRQ_LANCE];		dev->base_addr = KN01_LANCE_BASE;		dev->mem_start = KN01_LANCE_BASE + 0x01000000;		esar_base = KN01_RTC_BASE + 1;		lp->dma_irq = -1;		/*		 * setup the pointer arrays, this sucks [tm] :-(		 */		for (i = 0; i < RX_RING_SIZE; i++) {			lp->rx_buf_ptr_cpu[i] =				(char *)(dev->mem_start + BUF_OFFSET_CPU +					 2 * i * RX_BUFF_SIZE);			lp->rx_buf_ptr_lnc[i] =				(char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE);		}		for (i = 0; i < TX_RING_SIZE; i++) {			lp->tx_buf_ptr_cpu[i] =				(char *)(dev->mem_start + BUF_OFFSET_CPU +					 2 * RX_RING_SIZE * RX_BUFF_SIZE +					 2 * i * TX_BUFF_SIZE);			lp->tx_buf_ptr_lnc[i] =				(char *)(BUF_OFFSET_LNC +					 RX_RING_SIZE * RX_BUFF_SIZE +					 i * TX_BUFF_SIZE);		}		break;	default:		printk(KERN_ERR "%s: declance_init called with unknown type\n",			name);		ret = -ENODEV;		goto err_out_free_dev;	}	ll = (struct lance_regs *) dev->base_addr;	esar = (unsigned char *) esar_base;	/* prom checks */	/* First, check for test pattern */	if (esar[0x60] != 0xff && esar[0x64] != 0x00 &&	    esar[0x68] != 0x55 && esar[0x6c] != 0xaa) {		printk(KERN_ERR			"%s: Ethernet station address prom not found!\n",			name);		ret = -ENODEV;		goto err_out_free_dev;	}	/* Check the prom contents */	for (i = 0; i < 8; i++) {		if (esar[i * 4] != esar[0x3c - i * 4] &&		    esar[i * 4] != esar[0x40 + i * 4] &&		    esar[0x3c - i * 4] != esar[0x40 + i * 4]) {			printk(KERN_ERR "%s: Something is wrong with the "				"ethernet station address prom!\n", name);			ret = -ENODEV;			goto err_out_free_dev;		}	}	/* Copy the ethernet address to the device structure, later to the	 * lance initialization block so the lance gets it every time it's	 * (re)initialized.	 */	switch (type) {	case ASIC_LANCE:		printk("%s: IOASIC onboard LANCE, addr = ", name);		break;	case PMAD_LANCE:		printk("%s: PMAD-AA, addr = ", name);		break;	case PMAX_LANCE:		printk("%s: PMAX onboard LANCE, addr = ", name);		break;	}	for (i = 0; i < 6; i++) {		dev->dev_addr[i] = esar[i * 4];		printk("%2.2x%c", dev->dev_addr[i], i == 5 ? ',' : ':');	}	printk(" irq = %d\n", dev->irq);	dev->open = &lance_open;	dev->stop = &lance_close;	dev->hard_start_xmit = &lance_start_xmit;	dev->tx_timeout = &lance_tx_timeout;	dev->watchdog_timeo = 5*HZ;	dev->get_stats = &lance_get_stats;	dev->set_multicast_list = &lance_set_multicast;	/* lp->ll is the location of the registers for lance card */	lp->ll = ll;	/* busmaster_regval (CSR3) should be zero according to the PMAD-AA	 * specification.	 */	lp->busmaster_regval = 0;	dev->dma = 0;	/* We cannot sleep if the chip is busy during a	 * multicast list update event, because such events	 * can occur from interrupts (ex. IPv6).  So we	 * use a timer to try again later when necessary. -DaveM	 */	init_timer(&lp->multicast_timer);	lp->multicast_timer.data = (unsigned long) dev;	lp->multicast_timer.function = &lance_set_multicast_retry;	ret = register_netdev(dev);	if (ret) {		printk(KERN_ERR			"%s: Unable to register netdev, aborting.\n", name);		goto err_out_free_dev;	}	lp->next = root_lance_dev;	root_lance_dev = dev;	printk("%s: registered as %s.\n", name, dev->name);	return 0;err_out_free_dev:	kfree(dev);err_out:	return ret;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/6684b4e28247f31543edf86ba785aa87e8fa3b39/declance.c/buggy/drivers/net/declance.c