Example #1
0
/*
 * We cannot probe for a RIM I card; one reason is I don't know how to reset
 * them.  In fact, we can't even get their node ID automatically.  So, we
 * need to be passed a specific shmem address, IRQ, and node ID.
 */
static int __init arcrimi_probe(struct net_device *dev)
{
	BUGLVL(D_NORMAL) printk(VERSION);
	BUGLVL(D_NORMAL) printk("E-mail me if you actually test the RIM I driver, please!\n");

	BUGMSG(D_NORMAL, "Given: node %02Xh, shmem %lXh, irq %d\n",
	       dev->dev_addr[0], dev->mem_start, dev->irq);

	if (dev->mem_start <= 0 || dev->irq <= 0) {
		BUGMSG(D_NORMAL, "No autoprobe for RIM I; you "
		       "must specify the shmem and irq!\n");
		return -ENODEV;
	}
	if (dev->dev_addr[0] == 0) {
		BUGMSG(D_NORMAL, "You need to specify your card's station "
		       "ID!\n");
		return -ENODEV;
	}
	/*
	 * Grab the memory region at mem_start for MIRROR_SIZE bytes.
	 * Later in arcrimi_found() the real size will be determined
	 * and this reserve will be released and the correct size
	 * will be taken.
	 */
	if (!request_mem_region(dev->mem_start, MIRROR_SIZE, "arcnet (90xx)")) {
		BUGMSG(D_NORMAL, "Card memory already allocated\n");
		return -ENODEV;
	}
	return arcrimi_found(dev);
}
Example #2
0
static void
arcrimi_rx(struct device *dev,int recbuf)
{
  struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
  int ioaddr=dev->mem_start+0x800;
  union ArcPacket *arcpacket=
    (union ArcPacket *)phys_to_virt(dev->mem_start+recbuf*512);
  u_char *arcsoft;
  short length,offset;
  u_char daddr,saddr;

  lp->stats.rx_packets++;

  saddr=arcpacket->hardheader.source;

  /* if source is 0, it's a "used" packet! */
  if (saddr==0)
    {
      BUGMSG(D_NORMAL,"discarding old packet. (status=%Xh)\n",
	     ARCSTATUS);
      lp->stats.rx_errors++;
      return;
    }
  /* Set source address to zero to mark it as old */

  arcpacket->hardheader.source=0;

  daddr=arcpacket->hardheader.destination;

  if (arcpacket->hardheader.offset1) /* Normal Packet */
    {
      offset=arcpacket->hardheader.offset1;
      arcsoft=&arcpacket->raw[offset];
      length=256-offset;
    }
  else		/* ExtendedPacket or ExceptionPacket */
    {
      offset=arcpacket->hardheader.offset2;
      arcsoft=&arcpacket->raw[offset];

      length=512-offset;
    }

  arcnet_rx(lp, arcsoft, length, saddr, daddr);

  BUGLVL(D_RX) arcnet_dump_packet(lp->adev,arcpacket->raw,length>240,"rx");

#ifndef SLOW_XMIT_COPY
  /* clean out the page to make debugging make more sense :) */
  BUGLVL(D_DURING)
    memset((void *)arcpacket->raw,0x42,512);
#endif
}
Example #3
0
/*
 * Do a hardware reset on the card, and set up necessary registers.
 *
 * This should be called as little as possible, because it disrupts the
 * token on the network (causes a RECON) and requires a significant delay.
 *
 * However, it does make sure the card is in a defined state.
 */
static int com90xx_reset(struct net_device *dev, int really_reset)
{
	struct arcnet_local *lp = netdev_priv(dev);
	short ioaddr = dev->base_addr;

	BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", ASTATUS());

	if (really_reset) {
		/* reset the card */
		inb(_RESET);
		mdelay(RESETtime);
	}
	ACOMMAND(CFLAGScmd | RESETclear);	/* clear flags & end reset */
	ACOMMAND(CFLAGScmd | CONFIGclear);

	/* don't do this until we verify that it doesn't hurt older cards! */
	/* outb(inb(_CONFIG) | ENABLE16flag, _CONFIG); */

	/* verify that the ARCnet signature byte is present */
	if (readb(lp->mem_start) != TESTvalue) {
		if (really_reset)
			BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n");
		return 1;
	}
	/* enable extended (512-byte) packets */
	ACOMMAND(CONFIGcmd | EXTconf);

	/* clean out all the memory to make debugging make more sense :) */
	BUGLVL(D_DURING)
	    memset_io(lp->mem_start, 0x42, 2048);

	/* done!  return success. */
	return 0;
}
static int com90xx_reset(struct net_device *dev, int really_reset)
{
	struct arcnet_local *lp = netdev_priv(dev);
	short ioaddr = dev->base_addr;

	BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", ASTATUS());

	if (really_reset) {
		
		inb(_RESET);
		mdelay(RESETtime);
	}
	ACOMMAND(CFLAGScmd | RESETclear);	
	ACOMMAND(CFLAGScmd | CONFIGclear);

	
	

	
	if (readb(lp->mem_start) != TESTvalue) {
		if (really_reset)
			BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n");
		return 1;
	}
	
	ACOMMAND(CONFIGcmd | EXTconf);

	
	BUGLVL(D_DURING)
	    memset_io(lp->mem_start, 0x42, 2048);

	
	return 0;
}
Example #5
0
/*
 * We cannot (yet) probe for an IO mapped card, although we can check that
 * it's where we were told it was, and even do autoirq.
 */
static int __init com20020isa_probe(struct net_device *dev)
{
	int ioaddr;
	unsigned long airqmask;
	struct arcnet_local *lp = dev->priv;

#ifndef MODULE
	arcnet_init();
#endif

	BUGLVL(D_NORMAL) printk(VERSION);

	ioaddr = dev->base_addr;
	if (!ioaddr) {
		BUGMSG(D_NORMAL, "No autoprobe (yet) for IO mapped cards; you "
		       "must specify the base address!\n");
		return -ENODEV;
	}
	if (check_region(ioaddr, ARCNET_TOTAL_SIZE)) {
		BUGMSG(D_NORMAL, "IO region %xh-%xh already allocated.\n",
		       ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
		return -ENXIO;
	}
	if (ASTATUS() == 0xFF) {
		BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr);
		return -ENODEV;
	}
	if (com20020_check(dev))
		return -ENODEV;

	if (!dev->irq) {
		/* if we do this, we're sure to get an IRQ since the
		 * card has just reset and the NORXflag is on until
		 * we tell it to start receiving.
		 */
		BUGMSG(D_INIT_REASONS, "intmask was %02Xh\n", inb(_INTMASK));
		outb(0, _INTMASK);
		airqmask = probe_irq_on();
		outb(NORXflag, _INTMASK);
		udelay(1);
		outb(0, _INTMASK);
		dev->irq = probe_irq_off(airqmask);

		if (dev->irq <= 0) {
			BUGMSG(D_INIT_REASONS, "Autoprobe IRQ failed first time\n");
			airqmask = probe_irq_on();
			outb(NORXflag, _INTMASK);
			udelay(5);
			outb(0, _INTMASK);
			dev->irq = probe_irq_off(airqmask);
			if (dev->irq <= 0) {
				BUGMSG(D_NORMAL, "Autoprobe IRQ failed.\n");
				return -ENODEV;
			}
		}
	}

	lp->card_name = "ISA COM20020";
	return com20020_found(dev, 0);
}
Example #6
0
static int __init com20020pci_init(void)
{
	BUGLVL(D_NORMAL) printk(VERSION);
#ifndef MODULE
	arcnet_init();
#endif
	return pci_module_init(&com20020pci_driver);
}
static int ack_tx(struct net_device *dev, int acked)
{
  struct arcnet_local *lp = netdev_priv(dev);
  struct sk_buff *ackskb;
  struct archdr *ackpkt;
  int length=sizeof(struct arc_cap);

  BUGMSG(D_DURING, "capmode: ack_tx: protocol: %x: result: %d\n",
	 lp->outgoing.skb->protocol, acked);

  BUGLVL(D_SKB) arcnet_dump_skb(dev, lp->outgoing.skb, "ack_tx");

  /* Now alloc a skb to send back up through the layers: */
  ackskb = alloc_skb(length + ARC_HDR_SIZE , GFP_ATOMIC);
  if (ackskb == NULL) {
	  BUGMSG(D_NORMAL, "Memory squeeze, can't acknowledge.\n");
	  goto free_outskb;
  }

  skb_put(ackskb, length + ARC_HDR_SIZE );
  ackskb->dev = dev;

  skb_reset_mac_header(ackskb);
  ackpkt = (struct archdr *)skb_mac_header(ackskb);
  /* skb_pull(ackskb, ARC_HDR_SIZE); */


  skb_copy_from_linear_data(lp->outgoing.skb, ackpkt,
		ARC_HDR_SIZE + sizeof(struct arc_cap));
  ackpkt->soft.cap.proto=0; /* using protocol 0 for acknowledge */
  ackpkt->soft.cap.mes.ack=acked;

  BUGMSG(D_PROTO, "Ackknowledge for cap packet %x.\n",
	 *((int*)&ackpkt->soft.cap.cookie[0]));

  ackskb->protocol = __constant_htons(ETH_P_ARCNET);

  BUGLVL(D_SKB) arcnet_dump_skb(dev, ackskb, "ack_tx_recv");
  netif_rx(ackskb);

 free_outskb:
  dev_kfree_skb_irq(lp->outgoing.skb);
  lp->outgoing.proto = NULL; /* We are always finished when in this protocol */

  return 0;
}
Example #8
0
/* packet receiver */
static void rx(struct net_device *dev, int bufnum,
	       struct archdr *pkthdr, int length)
{
	struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
	struct sk_buff *skb;
	struct archdr *pkt = pkthdr;
	char *pktbuf, *pkthdrbuf;
	int ofs;

	BUGMSG(D_DURING, "it's a raw(cap) packet (length=%d)\n", length);

	if (length >= MinTU)
		ofs = 512 - length;
	else
		ofs = 256 - length;

	skb = alloc_skb(length + ARC_HDR_SIZE + sizeof(int), GFP_ATOMIC);
	if (skb == NULL) {
		BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
		lp->stats.rx_dropped++;
		return;
	}
	skb_put(skb, length + ARC_HDR_SIZE + sizeof(int));
	skb->dev = dev;

	pkt = (struct archdr *) skb->data;

	skb->mac.raw = skb->data;
	skb_pull(skb, ARC_HDR_SIZE);

	/* up to sizeof(pkt->soft) has already been copied from the card */
	/* squeeze in an int for the cap encapsulation */

	/* use these variables to be sure we count in bytes, not in
	   sizeof(struct archdr) */
	pktbuf=(char*)pkt;
	pkthdrbuf=(char*)pkthdr;
	memcpy(pktbuf, pkthdrbuf, ARC_HDR_SIZE+sizeof(pkt->soft.cap.proto));
	memcpy(pktbuf+ARC_HDR_SIZE+sizeof(pkt->soft.cap.proto)+sizeof(int),
	       pkthdrbuf+ARC_HDR_SIZE+sizeof(pkt->soft.cap.proto),
	       sizeof(struct archdr)-ARC_HDR_SIZE-sizeof(pkt->soft.cap.proto));

	if (length > sizeof(pkt->soft))
		lp->hw.copy_from_card(dev, bufnum, ofs + sizeof(pkt->soft),
				      pkt->soft.raw + sizeof(pkt->soft)
				      + sizeof(int),
				      length - sizeof(pkt->soft));

	BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");

	skb->protocol = __constant_htons(ETH_P_ARCNET);
;
	netif_rx(skb);
	dev->last_rx = jiffies;
}
static void rx(struct net_device *dev, int bufnum,
	       struct archdr *pkthdr, int length)
{
	struct arcnet_local *lp = netdev_priv(dev);
	struct sk_buff *skb;
	struct archdr *pkt = pkthdr;
	char *pktbuf, *pkthdrbuf;
	int ofs;

	BUGMSG(D_DURING, "it's a raw(cap) packet (length=%d)\n", length);

	if (length >= MinTU)
		ofs = 512 - length;
	else
		ofs = 256 - length;

	skb = alloc_skb(length + ARC_HDR_SIZE + sizeof(int), GFP_ATOMIC);
	if (skb == NULL) {
		BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
		dev->stats.rx_dropped++;
		return;
	}
	skb_put(skb, length + ARC_HDR_SIZE + sizeof(int));
	skb->dev = dev;
	skb_reset_mac_header(skb);
	pkt = (struct archdr *)skb_mac_header(skb);
	skb_pull(skb, ARC_HDR_SIZE);

	/*                                                               */
	/*                                             */

	/*                                                         
                          */
	pktbuf=(char*)pkt;
	pkthdrbuf=(char*)pkthdr;
	memcpy(pktbuf, pkthdrbuf, ARC_HDR_SIZE+sizeof(pkt->soft.cap.proto));
	memcpy(pktbuf+ARC_HDR_SIZE+sizeof(pkt->soft.cap.proto)+sizeof(int),
	       pkthdrbuf+ARC_HDR_SIZE+sizeof(pkt->soft.cap.proto),
	       sizeof(struct archdr)-ARC_HDR_SIZE-sizeof(pkt->soft.cap.proto));

	if (length > sizeof(pkt->soft))
		lp->hw.copy_from_card(dev, bufnum, ofs + sizeof(pkt->soft),
				      pkt->soft.raw + sizeof(pkt->soft)
				      + sizeof(int),
				      length - sizeof(pkt->soft));

	BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");

	skb->protocol = cpu_to_be16(ETH_P_ARCNET);
	netif_rx(skb);
}
Example #10
0
/*
 * We cannot probe for a RIM I card; one reason is I don't know how to reset
 * them.  In fact, we can't even get their node ID automatically.  So, we
 * need to be passed a specific shmem address, IRQ, and node ID.
 */
static int __init arcrimi_probe(struct net_device *dev)
{
	BUGLVL(D_NORMAL) printk(VERSION);
	BUGLVL(D_NORMAL) printk("E-mail me if you actually test the RIM I driver, please!\n");

	BUGMSG(D_NORMAL, "Given: node %02Xh, shmem %lXh, irq %d\n",
	       dev->dev_addr[0], dev->mem_start, dev->irq);

	if (dev->mem_start <= 0 || dev->irq <= 0) {
		BUGMSG(D_NORMAL, "No autoprobe for RIM I; you "
		       "must specify the shmem and irq!\n");
		return -ENODEV;
	}
	if (check_mem_region(dev->mem_start, BUFFER_SIZE)) {
		BUGMSG(D_NORMAL, "Card memory already allocated\n");
		return -ENODEV;
	}
	if (dev->dev_addr[0] == 0) {
		BUGMSG(D_NORMAL, "You need to specify your card's station "
		       "ID!\n");
		return -ENODEV;
	}
	return arcrimi_found(dev);
}
Example #11
0
/* Do a hardware reset on the card, and set up necessary registers.
 *
 * This should be called as little as possible, because it disrupts the
 * token on the network (causes a RECON) and requires a significant delay.
 *
 * However, it does make sure the card is in a defined state.
 */
int arcrimi_reset(struct device *dev,int reset_delay)
{
  struct arcnet_local *lp=(struct arcnet_local *)dev->priv;
  short ioaddr=dev->mem_start + 0x800;
  int recbuf=lp->recbuf;

  if (reset_delay==3)
    {
      ARCRESET;
      return 0;
    }

  /* no IRQ's, please! */
  lp->intmask=0;
  SETMASK;

  BUGMSG(D_INIT,"Resetting %s (status=%Xh)\n",
	 dev->name,ARCSTATUS);

  ACOMMAND(CFLAGScmd|RESETclear); /* clear flags & end reset */
  ACOMMAND(CFLAGScmd|CONFIGclear);

  /* clear out status variables */
  recbuf=lp->recbuf=0;
  lp->txbuf=2;

  /* enable extended (512-byte) packets */
  ACOMMAND(CONFIGcmd|EXTconf);

#ifndef SLOW_XMIT_COPY
  /* clean out all the memory to make debugging make more sense :) */
  BUGLVL(D_DURING)
    memset_io(dev->mem_start,0x42,2048);
#endif

  /* and enable receive of our first packet to the first buffer */
  EnableReceiver();

  /* re-enable interrupts */
  lp->intmask|=NORXflag;
#ifdef DETECT_RECONFIGS
  lp->intmask|=RECONflag;
#endif
  SETMASK;

  /* done!  return success. */
  return 0;
}
/*
 * We cannot (yet) probe for an IO mapped card, although we can check that
 * it's where we were told it was, and even do autoirq.
 */
static int __init com20020isa_probe(struct net_device *dev)
{
	int ioaddr;
	unsigned long airqmask;
	struct arcnet_local *lp = netdev_priv(dev);
	int err;

	BUGLVL(D_NORMAL) printk(VERSION);

	ioaddr = dev->base_addr;
	if (!ioaddr) {
		BUGMSG(D_NORMAL, "No autoprobe (yet) for IO mapped cards; you "
		       "must specify the base address!\n");
		return -ENODEV;
	}
	if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM20020)")) {
		BUGMSG(D_NORMAL, "IO region %xh-%xh already allocated.\n",
		       ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
		return -ENXIO;
	}
	if (ASTATUS() == 0xFF) {
		BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr);
		err = -ENODEV;
		goto out;
	}
	if (com20020_check(dev)) {
		err = -ENODEV;
		goto out;
	}

	if (!dev->irq) {
		/* if we do this, we're sure to get an IRQ since the
		 * card has just reset and the NORXflag is on until
		 * we tell it to start receiving.
		 */
		BUGMSG(D_INIT_REASONS, "intmask was %02Xh\n", inb(_INTMASK));
		outb(0, _INTMASK);
		airqmask = probe_irq_on();
		outb(NORXflag, _INTMASK);
		udelay(1);
		outb(0, _INTMASK);
		dev->irq = probe_irq_off(airqmask);

<<<<<<< HEAD
Example #13
0
/* packet receiver */
static void rx(struct net_device *dev, int bufnum,
           struct archdr *pkthdr, int length)
{
    struct arcnet_local *lp = dev->priv;
    struct sk_buff *skb;
    struct archdr *pkt = pkthdr;
    int ofs;

    BUGMSG(D_DURING, "it's a raw packet (length=%d)\n", length);

    if (length > MTU)
        ofs = 512 - length;
    else
        ofs = 256 - length;

    skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
    if (skb == NULL) {
        BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
        lp->stats.rx_dropped++;
        return;
    }
    skb_put(skb, length + ARC_HDR_SIZE);
    skb->dev = dev;

    pkt = (struct archdr *) skb->data;

    skb_reset_mac_header(skb);
    skb_pull(skb, ARC_HDR_SIZE);

    /* up to sizeof(pkt->soft) has already been copied from the card */
    memcpy(pkt, pkthdr, sizeof(struct archdr));
    if (length > sizeof(pkt->soft))
        lp->hw.copy_from_card(dev, bufnum, ofs + sizeof(pkt->soft),
                      pkt->soft.raw + sizeof(pkt->soft),
                      length - sizeof(pkt->soft));

    BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");

    skb->protocol = __constant_htons(ETH_P_ARCNET);
;
    netif_rx(skb);
    dev->last_rx = jiffies;
}
Example #14
0
/* We cannot probe for a RIM I card; one reason is I don't know how to reset
 * them.  In fact, we can't even get their node ID automatically.  So, we
 * need to be passed a specific shmem address, IRQ, and node ID.
 */
__initfunc(int arcrimi_probe(struct device *dev))
{
  BUGLVL(D_NORMAL) printk(version);
  BUGMSG(D_NORMAL,"Given: node %02Xh, shmem %lXh, irq %d\n",
	 dev->dev_addr[0],dev->mem_start,dev->irq);

  if (dev->mem_start<=0 || dev->irq<=0)
    {
      BUGMSG(D_NORMAL,"No autoprobe for RIM I; you "
	     "must specify the shmem and irq!\n");
      return -ENODEV;
    }

  if (dev->dev_addr[0]==0)
    {
      BUGMSG(D_NORMAL,"You need to specify your card's station "
	     "ID!\n");
      return -ENODEV;
    }

  return arcrimi_found(dev,dev->dev_addr[0],dev->irq,dev->mem_start);
}
Example #15
0
/* packet receiver */
static void rx(struct net_device *dev, int bufnum,
	       struct archdr *pkthdr, int length)
{
	struct arcnet_local *lp = netdev_priv(dev);
	struct sk_buff *skb;
	struct archdr *pkt = pkthdr;
	int ofs;

	arc_printk(D_DURING, dev, "it's a raw packet (length=%d)\n", length);

	if (length >= MinTU)
		ofs = 512 - length;
	else
		ofs = 256 - length;

	skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
	if (!skb) {
		dev->stats.rx_dropped++;
		return;
	}
	skb_put(skb, length + ARC_HDR_SIZE);
	skb->dev = dev;

	pkt = (struct archdr *)skb->data;

	/* up to sizeof(pkt->soft) has already been copied from the card */
	memcpy(pkt, pkthdr, sizeof(struct archdr));
	if (length > sizeof(pkt->soft))
		lp->hw.copy_from_card(dev, bufnum, ofs + sizeof(pkt->soft),
				      pkt->soft.raw + sizeof(pkt->soft),
				      length - sizeof(pkt->soft));

	if (BUGLVL(D_SKB))
		arcnet_dump_skb(dev, skb, "rx");

	skb->protocol = type_trans(skb, dev);
	netif_rx(skb);
}
Example #16
0
File: com90xx.c Project: nhanh0/hah
int __init com90xx_probe(struct net_device *dev)
{
    int count, status, ioaddr, numprint, airq, retval = -ENODEV,
                                               openparen = 0;
    unsigned long airqmask;
    int ports[(0x3f0 - 0x200) / 16 + 1] =
    {0};
    u_long shmems[(0xFF800 - 0xA0000) / 2048 + 1] =
    {0};
    int numports, numshmems, *port;
    u_long *shmem;

    if (!dev && com90xx_skip_probe)
        return -ENODEV;

#ifndef MODULE
    arcnet_init();
#endif

    BUGLVL(D_NORMAL) printk(VERSION);

    /* set up the arrays where we'll store the possible probe addresses */
    numports = numshmems = 0;
    if (dev && dev->base_addr)
        ports[numports++] = dev->base_addr;
    else
        for (count = 0x200; count <= 0x3f0; count += 16)
            ports[numports++] = count;
    if (dev && dev->mem_start)
        shmems[numshmems++] = dev->mem_start;
    else
        for (count = 0xA0000; count <= 0xFF800; count += 2048)
            shmems[numshmems++] = count;

    /* Stage 1: abandon any reserved ports, or ones with status==0xFF
     * (empty), and reset any others by reading the reset port.
     */
    numprint = -1;
    for (port = &ports[0]; port - ports < numports; port++) {
        numprint++;
        numprint %= 8;
        if (!numprint) {
            BUGMSG2(D_INIT, "\n");
            BUGMSG2(D_INIT, "S1: ");
        }
        BUGMSG2(D_INIT, "%Xh ", *port);

        ioaddr = *port;

        if (check_region(*port, ARCNET_TOTAL_SIZE)) {
            BUGMSG2(D_INIT_REASONS, "(check_region)\n");
            BUGMSG2(D_INIT_REASONS, "S1: ");
            BUGLVL(D_INIT_REASONS) numprint = 0;
            *port = ports[numports - 1];
            numports--;
            port--;
            continue;
        }
        if (ASTATUS() == 0xFF) {
            BUGMSG2(D_INIT_REASONS, "(empty)\n");
            BUGMSG2(D_INIT_REASONS, "S1: ");
            BUGLVL(D_INIT_REASONS) numprint = 0;
            *port = ports[numports - 1];
            numports--;
            port--;
            continue;
        }
        inb(_RESET);	/* begin resetting card */

        BUGMSG2(D_INIT_REASONS, "\n");
        BUGMSG2(D_INIT_REASONS, "S1: ");
        BUGLVL(D_INIT_REASONS) numprint = 0;
    }
    BUGMSG2(D_INIT, "\n");

    if (!numports) {
        BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n");
        return -ENODEV;
    }
    /* Stage 2: we have now reset any possible ARCnet cards, so we can't
     * do anything until they finish.  If D_INIT, print the list of
     * cards that are left.
     */
    numprint = -1;
    for (port = &ports[0]; port - ports < numports; port++) {
        numprint++;
        numprint %= 8;
        if (!numprint) {
            BUGMSG2(D_INIT, "\n");
            BUGMSG2(D_INIT, "S2: ");
        }
        BUGMSG2(D_INIT, "%Xh ", *port);
    }
    BUGMSG2(D_INIT, "\n");
    mdelay(RESETtime);

    /* Stage 3: abandon any shmem addresses that don't have the signature
     * 0xD1 byte in the right place, or are read-only.
     */
    numprint = -1;
    for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) {
        u_long ptr = *shmem;

        numprint++;
        numprint %= 8;
        if (!numprint) {
            BUGMSG2(D_INIT, "\n");
            BUGMSG2(D_INIT, "S3: ");
        }
        BUGMSG2(D_INIT, "%lXh ", *shmem);

        if (check_mem_region(*shmem, BUFFER_SIZE)) {
            BUGMSG2(D_INIT_REASONS, "(check_mem_region)\n");
            BUGMSG2(D_INIT_REASONS, "Stage 3: ");
            BUGLVL(D_INIT_REASONS) numprint = 0;
            *shmem = shmems[numshmems - 1];
            numshmems--;
            shmem--;
            continue;
        }
        if (isa_readb(ptr) != TESTvalue) {
            BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
                    isa_readb(ptr), TESTvalue);
            BUGMSG2(D_INIT_REASONS, "S3: ");
            BUGLVL(D_INIT_REASONS) numprint = 0;
            *shmem = shmems[numshmems - 1];
            numshmems--;
            shmem--;
            continue;
        }
        /* By writing 0x42 to the TESTvalue location, we also make
         * sure no "mirror" shmem areas show up - if they occur
         * in another pass through this loop, they will be discarded
         * because *cptr != TESTvalue.
         */
        isa_writeb(0x42, ptr);
        if (isa_readb(ptr) != 0x42) {
            BUGMSG2(D_INIT_REASONS, "(read only)\n");
            BUGMSG2(D_INIT_REASONS, "S3: ");
            *shmem = shmems[numshmems - 1];
            numshmems--;
            shmem--;
            continue;
        }
        BUGMSG2(D_INIT_REASONS, "\n");
        BUGMSG2(D_INIT_REASONS, "S3: ");
        BUGLVL(D_INIT_REASONS) numprint = 0;
    }
    BUGMSG2(D_INIT, "\n");

    if (!numshmems) {
        BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n");
        return -ENODEV;
    }
    /* Stage 4: something of a dummy, to report the shmems that are
     * still possible after stage 3.
     */
    numprint = -1;
    for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) {
        numprint++;
        numprint %= 8;
        if (!numprint) {
            BUGMSG2(D_INIT, "\n");
            BUGMSG2(D_INIT, "S4: ");
        }
        BUGMSG2(D_INIT, "%lXh ", *shmem);
    }
    BUGMSG2(D_INIT, "\n");

    /* Stage 5: for any ports that have the correct status, can disable
     * the RESET flag, and (if no irq is given) generate an autoirq,
     * register an ARCnet device.
     *
     * Currently, we can only register one device per probe, so quit
     * after the first one is found.
     */
    numprint = -1;
    for (port = &ports[0]; port - ports < numports; port++) {
        numprint++;
        numprint %= 8;
        if (!numprint) {
            BUGMSG2(D_INIT, "\n");
            BUGMSG2(D_INIT, "S5: ");
        }
        BUGMSG2(D_INIT, "%Xh ", *port);

        ioaddr = *port;
        status = ASTATUS();

        if ((status & 0x9D)
                != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
            BUGMSG2(D_INIT_REASONS, "(status=%Xh)\n", status);
            BUGMSG2(D_INIT_REASONS, "S5: ");
            BUGLVL(D_INIT_REASONS) numprint = 0;
            *port = ports[numports - 1];
            numports--;
            port--;
            continue;
        }
        ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
        status = ASTATUS();
        if (status & RESETflag) {
            BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
                    status);
            BUGMSG2(D_INIT_REASONS, "S5: ");
            BUGLVL(D_INIT_REASONS) numprint = 0;
            *port = ports[numports - 1];
            numports--;
            port--;
            continue;
        }
        /* skip this completely if an IRQ was given, because maybe
         * we're on a machine that locks during autoirq!
         */
        if (!dev || !dev->irq) {
            /* if we do this, we're sure to get an IRQ since the
             * card has just reset and the NORXflag is on until
             * we tell it to start receiving.
             */
            airqmask = probe_irq_on();
            AINTMASK(NORXflag);
            udelay(1);
            AINTMASK(0);
            airq = probe_irq_off(airqmask);

            if (airq <= 0) {
                BUGMSG2(D_INIT_REASONS, "(airq=%d)\n", airq);
                BUGMSG2(D_INIT_REASONS, "S5: ");
                BUGLVL(D_INIT_REASONS) numprint = 0;
                *port = ports[numports - 1];
                numports--;
                port--;
                continue;
            }
        } else {
            airq = dev->irq;
        }

        BUGMSG2(D_INIT, "(%d,", airq);
        openparen = 1;

        /* Everything seems okay.  But which shmem, if any, puts
         * back its signature byte when the card is reset?
         *
         * If there are multiple cards installed, there might be
         * multiple shmems still in the list.
         */
#ifdef FAST_PROBE
        if (numports > 1 || numshmems > 1) {
            inb(_RESET);
            mdelay(RESETtime);
        } else {
            /* just one shmem and port, assume they match */
            isa_writeb(TESTvalue, shmems[0]);
        }
#else
        inb(_RESET);
        mdelay(RESETtime);
#endif

        for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) {
            u_long ptr = *shmem;

            if (isa_readb(ptr) == TESTvalue) {	/* found one */
                BUGMSG2(D_INIT, "%lXh)\n", *shmem);
                openparen = 0;

                /* register the card */
                retval = com90xx_found(dev, *port, airq, *shmem);
                numprint = -1;

                /* remove shmem from the list */
                *shmem = shmems[numshmems - 1];
                numshmems--;

                break;	/* go to the next I/O port */
            } else {
                BUGMSG2(D_INIT_REASONS, "%Xh-", isa_readb(ptr));
            }
        }

        if (openparen) {
            BUGLVL(D_INIT) printk("no matching shmem)\n");
            BUGLVL(D_INIT_REASONS) printk("S5: ");
            BUGLVL(D_INIT_REASONS) numprint = 0;
        }
        *port = ports[numports - 1];
        numports--;
        port--;
    }

    BUGLVL(D_INIT_REASONS) printk("\n");

    /* Now put back TESTvalue on all leftover shmems. */
    for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++)
        isa_writeb(TESTvalue, *shmem);

    if (retval && dev && !numcards)
        BUGMSG2(D_NORMAL, "S5: No ARCnet cards found.\n");
    return retval;
}
static int __init com20020isa_probe(struct net_device *dev)
{
	int ioaddr;
	unsigned long airqmask;
	struct arcnet_local *lp = netdev_priv(dev);
	int err;

	BUGLVL(D_NORMAL) printk(VERSION);

	ioaddr = dev->base_addr;
	if (!ioaddr) {
		BUGMSG(D_NORMAL, "No autoprobe (yet) for IO mapped cards; you "
		       "must specify the base address!\n");
		return -ENODEV;
	}
	if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM20020)")) {
		BUGMSG(D_NORMAL, "IO region %xh-%xh already allocated.\n",
		       ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
		return -ENXIO;
	}
	if (ASTATUS() == 0xFF) {
		BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr);
		err = -ENODEV;
		goto out;
	}
	if (com20020_check(dev)) {
		err = -ENODEV;
		goto out;
	}

	if (!dev->irq) {
		BUGMSG(D_INIT_REASONS, "intmask was %02Xh\n", inb(_INTMASK));
		outb(0, _INTMASK);
		airqmask = probe_irq_on();
		outb(NORXflag, _INTMASK);
		udelay(1);
		outb(0, _INTMASK);
		dev->irq = probe_irq_off(airqmask);

		if ((int)dev->irq <= 0) {
			BUGMSG(D_INIT_REASONS, "Autoprobe IRQ failed first time\n");
			airqmask = probe_irq_on();
			outb(NORXflag, _INTMASK);
			udelay(5);
			outb(0, _INTMASK);
			dev->irq = probe_irq_off(airqmask);
			if ((int)dev->irq <= 0) {
				BUGMSG(D_NORMAL, "Autoprobe IRQ failed.\n");
				err = -ENODEV;
				goto out;
			}
		}
	}

	lp->card_name = "ISA COM20020";
	if ((err = com20020_found(dev, 0)) != 0)
		goto out;

	return 0;

out:
	release_region(ioaddr, ARCNET_TOTAL_SIZE);
	return err;
}
Example #18
0
__initfunc(int arc20020_probe(struct device *dev))
{
  int ioaddr=dev->base_addr,status,delayval;
  unsigned long airqmask;
  
  BUGLVL(D_NORMAL) printk(version);
  
  if (ioaddr<0x200)
    {
      BUGMSG(D_NORMAL,"No autoprobe for IO mapped cards; you "
	     "must specify the base address!\n");
      return -ENODEV;
    }
  
  if (check_region(ioaddr, ARCNET_TOTAL_SIZE))
    {
      BUGMSG(D_NORMAL,"IO region %xh-%xh already allocated.\n",
	     ioaddr,ioaddr+ARCNET_TOTAL_SIZE-1);
      return -ENXIO;
    }
  
  if (ARCSTATUS == 0xFF)
    {
      BUGMSG(D_NORMAL,"IO address %x empty\n",ioaddr);
      return -ENODEV;
    }
  
  ARCRESET0;
  JIFFER(RESETtime);
  
  status=ARCSTATUS;
  
  if ((status & 0x99) 
      !=  (NORXflag|TXFREEflag|RESETflag))
    {
      BUGMSG(D_NORMAL,"Status invalid (%Xh).\n",status);
      return -ENODEV;
    }
  
  BUGMSG(D_INIT_REASONS,"Status after reset: %X\n",status);
  
  /* Enable TX */
  outb(0x39,_CONFIG);
  outb(inb(ioaddr+8),ioaddr+7);
  
  ACOMMAND(CFLAGScmd|RESETclear|CONFIGclear);
  
  BUGMSG(D_INIT_REASONS,"Status after reset acknowledged: %X\n",status);
  
  /* Reset card. */
  
  outb(0x98,_CONFIG);
  udelay(5);
  outb(0x18,_CONFIG);
  
  /* Read first loc'n of memory */
  
  outb(0 | RDDATAflag | AUTOINCflag ,_ADDR_HI);
  outb(0,_ADDR_LO);
  
  if ((status=inb(_MEMDATA)) != 0xd1)
    {
      BUGMSG(D_NORMAL,"Signature byte not found.\n");
      return -ENODEV;
    }
  
  if (!dev->irq)
    {
      /* if we do this, we're sure to get an IRQ since the
       * card has just reset and the NORXflag is on until
       * we tell it to start receiving.
       */
      BUGMSG(D_INIT_REASONS, "intmask was %d:\n",inb(_INTMASK));
      outb(0, _INTMASK);      
      airqmask = probe_irq_on();
      outb(NORXflag,_INTMASK);
      udelay(1);
      outb(0,_INTMASK);
      dev->irq = probe_irq_off(airqmask);
      
      if (dev->irq<=0)
	{
	  BUGMSG(D_INIT_REASONS,"Autoprobe IRQ failed first time\n");
          airqmask = probe_irq_on();
          outb(NORXflag,_INTMASK);
          udelay(5);
          outb(0,_INTMASK);
          dev->irq = probe_irq_off(airqmask);
          if (dev->irq<=0)
	    {
	      BUGMSG(D_NORMAL,"Autoprobe IRQ failed.\n");
	      return -ENODEV;
            }
	}
    }
  
  return arc20020_found(dev,dev->base_addr,dev->irq);
}
Example #19
0
/*
 * We cannot probe for an IO mapped card either, although we can check that
 * it's where we were told it was, and even autoirq
 */
static int __init com90io_probe(struct net_device *dev)
{
	int ioaddr = dev->base_addr, status;
	unsigned long airqmask;

	BUGLVL(D_NORMAL) printk(VERSION);
	BUGLVL(D_NORMAL) printk("E-mail me if you actually test this driver, please!\n");

	if (!ioaddr) {
		BUGMSG(D_NORMAL, "No autoprobe for IO mapped cards; you "
		       "must specify the base address!\n");
		return -ENODEV;
	}
	if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com90io probe")) {
		BUGMSG(D_INIT_REASONS, "IO request_region %x-%x failed.\n",
		       ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
		return -ENXIO;
	}
	if (ASTATUS() == 0xFF) {
		BUGMSG(D_INIT_REASONS, "IO address %x empty\n", ioaddr);
		goto err_out;
	}
	inb(_RESET);
	mdelay(RESETtime);

	status = ASTATUS();

	if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
		BUGMSG(D_INIT_REASONS, "Status invalid (%Xh).\n", status);
		goto err_out;
	}
	BUGMSG(D_INIT_REASONS, "Status after reset: %X\n", status);

	ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);

	BUGMSG(D_INIT_REASONS, "Status after reset acknowledged: %X\n", status);

	status = ASTATUS();

	if (status & RESETflag) {
		BUGMSG(D_INIT_REASONS, "Eternal reset (status=%Xh)\n", status);
		goto err_out;
	}
	outb((0x16 | IOMAPflag) & ~ENABLE16flag, _CONFIG);

	/* Read first loc'n of memory */

	outb(AUTOINCflag, _ADDR_HI);
	outb(0, _ADDR_LO);

	if ((status = inb(_MEMDATA)) != 0xd1) {
		BUGMSG(D_INIT_REASONS, "Signature byte not found"
		       " (%Xh instead).\n", status);
		goto err_out;
	}
	if (!dev->irq) {
		/*
		 * if we do this, we're sure to get an IRQ since the
		 * card has just reset and the NORXflag is on until
		 * we tell it to start receiving.
		 */

		airqmask = probe_irq_on();
		outb(NORXflag, _INTMASK);
		udelay(1);
		outb(0, _INTMASK);
		dev->irq = probe_irq_off(airqmask);

		if (dev->irq <= 0) {
			BUGMSG(D_INIT_REASONS, "Autoprobe IRQ failed\n");
			goto err_out;
		}
	}
	release_region(ioaddr, ARCNET_TOTAL_SIZE); /* end of probing */
	return com90io_found(dev);

err_out:
	release_region(ioaddr, ARCNET_TOTAL_SIZE);
	return -ENODEV;
}
/* packet receiver */
static void rx(struct net_device *dev, int bufnum,
	       struct archdr *pkthdr, int length)
{
	struct arcnet_local *lp = netdev_priv(dev);
	struct sk_buff *skb;
	struct archdr *pkt = pkthdr;
	struct arc_rfc1201 *soft = &pkthdr->soft.rfc1201;
	int saddr = pkt->hard.source, ofs;
	struct Incoming *in = &lp->rfc1201.incoming[saddr];

	BUGMSG(D_DURING, "it's an RFC1201 packet (length=%d)\n", length);

	if (length >= MinTU)
		ofs = 512 - length;
	else
		ofs = 256 - length;

	if (soft->split_flag == 0xFF) {		/* Exception Packet */
		if (length >= 4 + RFC1201_HDR_SIZE)
			BUGMSG(D_DURING, "compensating for exception packet\n");
		else {
			BUGMSG(D_EXTRA, "short RFC1201 exception packet from %02Xh",
			       saddr);
			return;
		}

		/* skip over 4-byte junkola */
		length -= 4;
		ofs += 4;
		lp->hw.copy_from_card(dev, bufnum, 512 - length,
				      soft, sizeof(pkt->soft));
	}
	if (!soft->split_flag) {	/* not split */
		BUGMSG(D_RX, "incoming is not split (splitflag=%d)\n",
		       soft->split_flag);

		if (in->skb) {	/* already assembling one! */
			BUGMSG(D_EXTRA, "aborting assembly (seq=%d) for unsplit packet (splitflag=%d, seq=%d)\n",
			 in->sequence, soft->split_flag, soft->sequence);
			lp->rfc1201.aborted_seq = soft->sequence;
			dev_kfree_skb_irq(in->skb);
			lp->stats.rx_errors++;
			lp->stats.rx_missed_errors++;
			in->skb = NULL;
		}
		in->sequence = soft->sequence;

		skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
		if (skb == NULL) {
			BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
			lp->stats.rx_dropped++;
			return;
		}
		skb_put(skb, length + ARC_HDR_SIZE);
		skb->dev = dev;

		pkt = (struct archdr *) skb->data;
		soft = &pkt->soft.rfc1201;

		/* up to sizeof(pkt->soft) has already been copied from the card */
		memcpy(pkt, pkthdr, sizeof(struct archdr));
		if (length > sizeof(pkt->soft))
			lp->hw.copy_from_card(dev, bufnum, ofs + sizeof(pkt->soft),
				       pkt->soft.raw + sizeof(pkt->soft),
					      length - sizeof(pkt->soft));

		/*
		 * ARP packets have problems when sent from some DOS systems: the
		 * source address is always 0!  So we take the hardware source addr
		 * (which is impossible to fumble) and insert it ourselves.
		 */
		if (soft->proto == ARC_P_ARP) {
			struct arphdr *arp = (struct arphdr *) soft->payload;

			/* make sure addresses are the right length */
			if (arp->ar_hln == 1 && arp->ar_pln == 4) {
				uint8_t *cptr = (uint8_t *) arp + sizeof(struct arphdr);

				if (!*cptr) {	/* is saddr = 00? */
					BUGMSG(D_EXTRA,
					       "ARP source address was 00h, set to %02Xh.\n",
					       saddr);
					lp->stats.rx_crc_errors++;
					*cptr = saddr;
				} else {
					BUGMSG(D_DURING, "ARP source address (%Xh) is fine.\n",
					       *cptr);
				}
			} else {
				BUGMSG(D_NORMAL, "funny-shaped ARP packet. (%Xh, %Xh)\n",
				       arp->ar_hln, arp->ar_pln);
				lp->stats.rx_errors++;
				lp->stats.rx_crc_errors++;
			}
		}
		BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");

		skb->protocol = type_trans(skb, dev);
		netif_rx(skb);
	} else {		/* split packet */
		/*
		 * NOTE: MSDOS ARP packet correction should only need to apply to
		 * unsplit packets, since ARP packets are so short.
		 *
		 * My interpretation of the RFC1201 document is that if a packet is
		 * received out of order, the entire assembly process should be
		 * aborted.
		 *
		 * The RFC also mentions "it is possible for successfully received
		 * packets to be retransmitted." As of 0.40 all previously received
		 * packets are allowed, not just the most recent one.
		 *
		 * We allow multiple assembly processes, one for each ARCnet card
		 * possible on the network.  Seems rather like a waste of memory,
		 * but there's no other way to be reliable.
		 */

		BUGMSG(D_RX, "packet is split (splitflag=%d, seq=%d)\n",
		       soft->split_flag, in->sequence);

		if (in->skb && in->sequence != soft->sequence) {
			BUGMSG(D_EXTRA, "wrong seq number (saddr=%d, expected=%d, seq=%d, splitflag=%d)\n",
			       saddr, in->sequence, soft->sequence,
			       soft->split_flag);
			dev_kfree_skb_irq(in->skb);
			in->skb = NULL;
			lp->stats.rx_errors++;
			lp->stats.rx_missed_errors++;
			in->lastpacket = in->numpackets = 0;
		}
		if (soft->split_flag & 1) {	/* first packet in split */
			BUGMSG(D_RX, "brand new splitpacket (splitflag=%d)\n",
			       soft->split_flag);
			if (in->skb) {	/* already assembling one! */
				BUGMSG(D_EXTRA, "aborting previous (seq=%d) assembly "
				       "(splitflag=%d, seq=%d)\n",
				       in->sequence, soft->split_flag,
				       soft->sequence);
				lp->stats.rx_errors++;
				lp->stats.rx_missed_errors++;
				dev_kfree_skb_irq(in->skb);
			}
			in->sequence = soft->sequence;
			in->numpackets = ((unsigned) soft->split_flag >> 1) + 2;
			in->lastpacket = 1;

			if (in->numpackets > 16) {
				BUGMSG(D_EXTRA, "incoming packet more than 16 segments; dropping. (splitflag=%d)\n",
				       soft->split_flag);
				lp->rfc1201.aborted_seq = soft->sequence;
				lp->stats.rx_errors++;
				lp->stats.rx_length_errors++;
				return;
			}
			in->skb = skb = alloc_skb(508 * in->numpackets + ARC_HDR_SIZE,
						  GFP_ATOMIC);
			if (skb == NULL) {
				BUGMSG(D_NORMAL, "(split) memory squeeze, dropping packet.\n");
				lp->rfc1201.aborted_seq = soft->sequence;
				lp->stats.rx_dropped++;
				return;
			}
			skb->dev = dev;
			pkt = (struct archdr *) skb->data;
			soft = &pkt->soft.rfc1201;

			memcpy(pkt, pkthdr, ARC_HDR_SIZE + RFC1201_HDR_SIZE);
			skb_put(skb, ARC_HDR_SIZE + RFC1201_HDR_SIZE);

			soft->split_flag = 0;	/* end result won't be split */
		} else {	/* not first packet */
Example #21
0
static int __init com20020pci_init(void)
{
	BUGLVL(D_NORMAL) printk(VERSION);
	return pci_register_driver(&com20020pci_driver);
}
static void __init com90xx_probe(void)
{
	int count, status, ioaddr, numprint, airq, openparen = 0;
	unsigned long airqmask;
	int ports[(0x3f0 - 0x200) / 16 + 1] =
	{0};
	unsigned long *shmems;
	void __iomem **iomem;
	int numports, numshmems, *port;
	u_long *p;
	int index;

	if (!io && !irq && !shmem && !*device && com90xx_skip_probe)
		return;

	shmems = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(unsigned long),
			 GFP_KERNEL);
	if (!shmems)
		return;
	iomem = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(void __iomem *),
			 GFP_KERNEL);
	if (!iomem) {
		kfree(shmems);
		return;
	}

	BUGLVL(D_NORMAL) printk(VERSION);

	
	numports = numshmems = 0;
	if (io)
		ports[numports++] = io;
	else
		for (count = 0x200; count <= 0x3f0; count += 16)
			ports[numports++] = count;
	if (shmem)
		shmems[numshmems++] = shmem;
	else
		for (count = 0xA0000; count <= 0xFF800; count += 2048)
			shmems[numshmems++] = count;

	numprint = -1;
	for (port = &ports[0]; port - ports < numports; port++) {
		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S1: ");
		}
		BUGMSG2(D_INIT, "%Xh ", *port);

		ioaddr = *port;

		if (!request_region(*port, ARCNET_TOTAL_SIZE, "arcnet (90xx)")) {
			BUGMSG2(D_INIT_REASONS, "(request_region)\n");
			BUGMSG2(D_INIT_REASONS, "S1: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			*port-- = ports[--numports];
			continue;
		}
		if (ASTATUS() == 0xFF) {
			BUGMSG2(D_INIT_REASONS, "(empty)\n");
			BUGMSG2(D_INIT_REASONS, "S1: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			release_region(*port, ARCNET_TOTAL_SIZE);
			*port-- = ports[--numports];
			continue;
		}
		inb(_RESET);	

		BUGMSG2(D_INIT_REASONS, "\n");
		BUGMSG2(D_INIT_REASONS, "S1: ");
		BUGLVL(D_INIT_REASONS) numprint = 0;
	}
	BUGMSG2(D_INIT, "\n");

	if (!numports) {
		BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n");
		kfree(shmems);
		kfree(iomem);
		return;
	}
	numprint = -1;
	for (port = &ports[0]; port < ports + numports; port++) {
		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S2: ");
		}
		BUGMSG2(D_INIT, "%Xh ", *port);
	}
	BUGMSG2(D_INIT, "\n");
	mdelay(RESETtime);

	numprint = -1;
	for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) {
		void __iomem *base;

		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S3: ");
		}
		BUGMSG2(D_INIT, "%lXh ", *p);

		if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) {
			BUGMSG2(D_INIT_REASONS, "(request_mem_region)\n");
			BUGMSG2(D_INIT_REASONS, "Stage 3: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			goto out;
		}
		base = ioremap(*p, MIRROR_SIZE);
		if (!base) {
			BUGMSG2(D_INIT_REASONS, "(ioremap)\n");
			BUGMSG2(D_INIT_REASONS, "Stage 3: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			goto out1;
		}
		if (readb(base) != TESTvalue) {
			BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
				readb(base), TESTvalue);
			BUGMSG2(D_INIT_REASONS, "S3: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			goto out2;
		}
		writeb(0x42, base);
		if (readb(base) != 0x42) {
			BUGMSG2(D_INIT_REASONS, "(read only)\n");
			BUGMSG2(D_INIT_REASONS, "S3: ");
			goto out2;
		}
		BUGMSG2(D_INIT_REASONS, "\n");
		BUGMSG2(D_INIT_REASONS, "S3: ");
		BUGLVL(D_INIT_REASONS) numprint = 0;
		iomem[index] = base;
		continue;
	out2:
		iounmap(base);
	out1:
		release_mem_region(*p, MIRROR_SIZE);
	out:
		*p-- = shmems[--numshmems];
		index--;
	}
	BUGMSG2(D_INIT, "\n");

	if (!numshmems) {
		BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n");
		for (port = &ports[0]; port < ports + numports; port++)
			release_region(*port, ARCNET_TOTAL_SIZE);
		kfree(shmems);
		kfree(iomem);
		return;
	}
	numprint = -1;
	for (p = &shmems[0]; p < shmems + numshmems; p++) {
		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S4: ");
		}
		BUGMSG2(D_INIT, "%lXh ", *p);
	}
	BUGMSG2(D_INIT, "\n");

	numprint = -1;
	for (port = &ports[0]; port < ports + numports; port++) {
		int found = 0;
		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S5: ");
		}
		BUGMSG2(D_INIT, "%Xh ", *port);

		ioaddr = *port;
		status = ASTATUS();

		if ((status & 0x9D)
		    != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
			BUGMSG2(D_INIT_REASONS, "(status=%Xh)\n", status);
			BUGMSG2(D_INIT_REASONS, "S5: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			release_region(*port, ARCNET_TOTAL_SIZE);
			*port-- = ports[--numports];
			continue;
		}
		ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
		status = ASTATUS();
		if (status & RESETflag) {
			BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
				status);
			BUGMSG2(D_INIT_REASONS, "S5: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			release_region(*port, ARCNET_TOTAL_SIZE);
			*port-- = ports[--numports];
			continue;
		}
		if (!irq) {
			airqmask = probe_irq_on();
			AINTMASK(NORXflag);
			udelay(1);
			AINTMASK(0);
			airq = probe_irq_off(airqmask);

			if (airq <= 0) {
				BUGMSG2(D_INIT_REASONS, "(airq=%d)\n", airq);
				BUGMSG2(D_INIT_REASONS, "S5: ");
				BUGLVL(D_INIT_REASONS) numprint = 0;
				release_region(*port, ARCNET_TOTAL_SIZE);
				*port-- = ports[--numports];
				continue;
			}
		} else {
			airq = irq;
		}

		BUGMSG2(D_INIT, "(%d,", airq);
		openparen = 1;

#ifdef FAST_PROBE
		if (numports > 1 || numshmems > 1) {
			inb(_RESET);
			mdelay(RESETtime);
		} else {
			
			writeb(TESTvalue, iomem[0]);
		}
#else
		inb(_RESET);
		mdelay(RESETtime);
#endif

		for (index = 0; index < numshmems; index++) {
			u_long ptr = shmems[index];
			void __iomem *base = iomem[index];

			if (readb(base) == TESTvalue) {	
				BUGMSG2(D_INIT, "%lXh)\n", *p);
				openparen = 0;

				
				if (com90xx_found(*port, airq, ptr, base) == 0)
					found = 1;
				numprint = -1;

				
				shmems[index] = shmems[--numshmems];
				iomem[index] = iomem[numshmems];
				break;	
			} else {
				BUGMSG2(D_INIT_REASONS, "%Xh-", readb(base));
			}
		}

		if (openparen) {
			BUGLVL(D_INIT) printk("no matching shmem)\n");
			BUGLVL(D_INIT_REASONS) printk("S5: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
		}
		if (!found)
			release_region(*port, ARCNET_TOTAL_SIZE);
		*port-- = ports[--numports];
	}

	BUGLVL(D_INIT_REASONS) printk("\n");

	
	for (index = 0; index < numshmems; index++) {
		writeb(TESTvalue, iomem[index]);
		iounmap(iomem[index]);
		release_mem_region(shmems[index], MIRROR_SIZE);
	}
	kfree(shmems);
	kfree(iomem);
}
Example #23
0
static void __init com90xx_probe(void)
{
	int count, status, ioaddr, numprint, airq, openparen = 0;
	unsigned long airqmask;
	int ports[(0x3f0 - 0x200) / 16 + 1] =
	{0};
	unsigned long *shmems;
	void __iomem **iomem;
	int numports, numshmems, *port;
	u_long *p;
	int index;

	if (!io && !irq && !shmem && !*device && com90xx_skip_probe)
		return;

	shmems = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(unsigned long),
			 GFP_KERNEL);
	if (!shmems)
		return;
	iomem = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(void __iomem *),
			 GFP_KERNEL);
	if (!iomem) {
		kfree(shmems);
		return;
	}

	BUGLVL(D_NORMAL) printk(VERSION);

	/* set up the arrays where we'll store the possible probe addresses */
	numports = numshmems = 0;
	if (io)
		ports[numports++] = io;
	else
		for (count = 0x200; count <= 0x3f0; count += 16)
			ports[numports++] = count;
	if (shmem)
		shmems[numshmems++] = shmem;
	else
		for (count = 0xA0000; count <= 0xFF800; count += 2048)
			shmems[numshmems++] = count;

	/* Stage 1: abandon any reserved ports, or ones with status==0xFF
	 * (empty), and reset any others by reading the reset port.
	 */
	numprint = -1;
	for (port = &ports[0]; port - ports < numports; port++) {
		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S1: ");
		}
		BUGMSG2(D_INIT, "%Xh ", *port);

		ioaddr = *port;

		if (!request_region(*port, ARCNET_TOTAL_SIZE, "arcnet (90xx)")) {
			BUGMSG2(D_INIT_REASONS, "(request_region)\n");
			BUGMSG2(D_INIT_REASONS, "S1: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			*port-- = ports[--numports];
			continue;
		}
		if (ASTATUS() == 0xFF) {
			BUGMSG2(D_INIT_REASONS, "(empty)\n");
			BUGMSG2(D_INIT_REASONS, "S1: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			release_region(*port, ARCNET_TOTAL_SIZE);
			*port-- = ports[--numports];
			continue;
		}
		inb(_RESET);	/* begin resetting card */

		BUGMSG2(D_INIT_REASONS, "\n");
		BUGMSG2(D_INIT_REASONS, "S1: ");
		BUGLVL(D_INIT_REASONS) numprint = 0;
	}
	BUGMSG2(D_INIT, "\n");

	if (!numports) {
		BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n");
		kfree(shmems);
		kfree(iomem);
		return;
	}
	/* Stage 2: we have now reset any possible ARCnet cards, so we can't
	 * do anything until they finish.  If D_INIT, print the list of
	 * cards that are left.
	 */
	numprint = -1;
	for (port = &ports[0]; port < ports + numports; port++) {
		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S2: ");
		}
		BUGMSG2(D_INIT, "%Xh ", *port);
	}
	BUGMSG2(D_INIT, "\n");
	mdelay(RESETtime);

	/* Stage 3: abandon any shmem addresses that don't have the signature
	 * 0xD1 byte in the right place, or are read-only.
	 */
	numprint = -1;
	for (index = 0, p = &shmems[0]; index < numshmems; p++, index++) {
		void __iomem *base;

		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S3: ");
		}
		BUGMSG2(D_INIT, "%lXh ", *p);

		if (!request_mem_region(*p, MIRROR_SIZE, "arcnet (90xx)")) {
			BUGMSG2(D_INIT_REASONS, "(request_mem_region)\n");
			BUGMSG2(D_INIT_REASONS, "Stage 3: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			goto out;
		}
		base = ioremap(*p, MIRROR_SIZE);
		if (!base) {
			BUGMSG2(D_INIT_REASONS, "(ioremap)\n");
			BUGMSG2(D_INIT_REASONS, "Stage 3: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			goto out1;
		}
		if (readb(base) != TESTvalue) {
			BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
				readb(base), TESTvalue);
			BUGMSG2(D_INIT_REASONS, "S3: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			goto out2;
		}
		/* By writing 0x42 to the TESTvalue location, we also make
		 * sure no "mirror" shmem areas show up - if they occur
		 * in another pass through this loop, they will be discarded
		 * because *cptr != TESTvalue.
		 */
		writeb(0x42, base);
		if (readb(base) != 0x42) {
			BUGMSG2(D_INIT_REASONS, "(read only)\n");
			BUGMSG2(D_INIT_REASONS, "S3: ");
			goto out2;
		}
		BUGMSG2(D_INIT_REASONS, "\n");
		BUGMSG2(D_INIT_REASONS, "S3: ");
		BUGLVL(D_INIT_REASONS) numprint = 0;
		iomem[index] = base;
		continue;
	out2:
		iounmap(base);
	out1:
		release_mem_region(*p, MIRROR_SIZE);
	out:
		*p-- = shmems[--numshmems];
		index--;
	}
	BUGMSG2(D_INIT, "\n");

	if (!numshmems) {
		BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n");
		for (port = &ports[0]; port < ports + numports; port++)
			release_region(*port, ARCNET_TOTAL_SIZE);
		kfree(shmems);
		kfree(iomem);
		return;
	}
	/* Stage 4: something of a dummy, to report the shmems that are
	 * still possible after stage 3.
	 */
	numprint = -1;
	for (p = &shmems[0]; p < shmems + numshmems; p++) {
		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S4: ");
		}
		BUGMSG2(D_INIT, "%lXh ", *p);
	}
	BUGMSG2(D_INIT, "\n");

	/* Stage 5: for any ports that have the correct status, can disable
	 * the RESET flag, and (if no irq is given) generate an autoirq,
	 * register an ARCnet device.
	 *
	 * Currently, we can only register one device per probe, so quit
	 * after the first one is found.
	 */
	numprint = -1;
	for (port = &ports[0]; port < ports + numports; port++) {
		int found = 0;
		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S5: ");
		}
		BUGMSG2(D_INIT, "%Xh ", *port);

		ioaddr = *port;
		status = ASTATUS();

		if ((status & 0x9D)
		    != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
			BUGMSG2(D_INIT_REASONS, "(status=%Xh)\n", status);
			BUGMSG2(D_INIT_REASONS, "S5: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			release_region(*port, ARCNET_TOTAL_SIZE);
			*port-- = ports[--numports];
			continue;
		}
		ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
		status = ASTATUS();
		if (status & RESETflag) {
			BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
				status);
			BUGMSG2(D_INIT_REASONS, "S5: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			release_region(*port, ARCNET_TOTAL_SIZE);
			*port-- = ports[--numports];
			continue;
		}
		/* skip this completely if an IRQ was given, because maybe
		 * we're on a machine that locks during autoirq!
		 */
		if (!irq) {
			/* if we do this, we're sure to get an IRQ since the
			 * card has just reset and the NORXflag is on until
			 * we tell it to start receiving.
			 */
			airqmask = probe_irq_on();
			AINTMASK(NORXflag);
			udelay(1);
			AINTMASK(0);
			airq = probe_irq_off(airqmask);

			if (airq <= 0) {
				BUGMSG2(D_INIT_REASONS, "(airq=%d)\n", airq);
				BUGMSG2(D_INIT_REASONS, "S5: ");
				BUGLVL(D_INIT_REASONS) numprint = 0;
				release_region(*port, ARCNET_TOTAL_SIZE);
				*port-- = ports[--numports];
				continue;
			}
		} else {
			airq = irq;
		}

		BUGMSG2(D_INIT, "(%d,", airq);
		openparen = 1;

		/* Everything seems okay.  But which shmem, if any, puts
		 * back its signature byte when the card is reset?
		 *
		 * If there are multiple cards installed, there might be
		 * multiple shmems still in the list.
		 */
#ifdef FAST_PROBE
		if (numports > 1 || numshmems > 1) {
			inb(_RESET);
			mdelay(RESETtime);
		} else {
			/* just one shmem and port, assume they match */
			writeb(TESTvalue, iomem[0]);
		}
#else
		inb(_RESET);
		mdelay(RESETtime);
#endif

		for (index = 0; index < numshmems; index++) {
			u_long ptr = shmems[index];
			void __iomem *base = iomem[index];

			if (readb(base) == TESTvalue) {	/* found one */
				BUGMSG2(D_INIT, "%lXh)\n", *p);
				openparen = 0;

				/* register the card */
				if (com90xx_found(*port, airq, ptr, base) == 0)
					found = 1;
				numprint = -1;

				/* remove shmem from the list */
				shmems[index] = shmems[--numshmems];
				iomem[index] = iomem[numshmems];
				break;	/* go to the next I/O port */
			} else {
				BUGMSG2(D_INIT_REASONS, "%Xh-", readb(base));
			}
		}

		if (openparen) {
			BUGLVL(D_INIT) printk("no matching shmem)\n");
			BUGLVL(D_INIT_REASONS) printk("S5: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
		}
		if (!found)
			release_region(*port, ARCNET_TOTAL_SIZE);
		*port-- = ports[--numports];
	}

	BUGLVL(D_INIT_REASONS) printk("\n");

	/* Now put back TESTvalue on all leftover shmems. */
	for (index = 0; index < numshmems; index++) {
		writeb(TESTvalue, iomem[index]);
		iounmap(iomem[index]);
		release_mem_region(shmems[index], MIRROR_SIZE);
	}
	kfree(shmems);
	kfree(iomem);
}
Example #24
0
/* Given an skb, copy a packet into the ARCnet buffers for later transmission
 * by arcnet_go_tx.
 */
static void
arcrimi_prepare_tx(struct device *dev,u_char *hdr,int hdrlen,
		   char *data,int length,int daddr,int exceptA, int offset)
{
  struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
  union ArcPacket *arcpacket =
    (union ArcPacket *)phys_to_virt(dev->mem_start+512*(lp->txbuf^1));

#ifdef SLOW_XMIT_COPY
  char *iptr,*iend,*optr;
#endif

  lp->txbuf=lp->txbuf^1;	/* XOR with 1 to alternate between 2 and 3 */

  length+=hdrlen;

  BUGMSG(D_TX,"arcnetAS_prep_tx: hdr:%ph, length:%d, data:%ph\n",
	 hdr,length,data);

#ifndef SLOW_XMIT_COPY
  /* clean out the page to make debugging make more sense :) */
  BUGLVL(D_DURING)
    memset_io(dev->mem_start+lp->txbuf*512,0x42,512);
#endif

  arcpacket->hardheader.destination=daddr;

  /* load packet into shared memory */
  if (length<=MTU)	/* Normal (256-byte) Packet */
    arcpacket->hardheader.offset1=offset=offset?offset:256-length;

  else if (length>=MinTU || offset)	/* Extended (512-byte) Packet */
    {
      arcpacket->hardheader.offset1=0;
      arcpacket->hardheader.offset2=offset=offset?offset:512-length;
    }
  else if (exceptA)		/* RFC1201 Exception Packet */
    {
      arcpacket->hardheader.offset1=0;
      arcpacket->hardheader.offset2=offset=512-length-4;

      /* exception-specific stuff - these four bytes
       * make the packet long enough to fit in a 512-byte
       * frame.
       */

      arcpacket->raw[offset+0]=hdr[0];
      arcpacket->raw[offset+1]=0xFF; /* FF flag */
      arcpacket->raw[offset+2]=0xFF; /* FF padding */
      arcpacket->raw[offset+3]=0xFF; /* FF padding */
      offset+=4;
    }
  else				/* "other" Exception packet */
    {
      /* RFC1051 - set 4 trailing bytes to 0 */
      memset(&arcpacket->raw[508],0,4);

      /* now round up to MinTU */
      arcpacket->hardheader.offset1=0;
      arcpacket->hardheader.offset2=offset=512-MinTU;
    }


  /* copy the packet into ARCnet shmem
   *  - the first bytes of ClientData header are skipped
   */

  memcpy((u_char*)arcpacket+offset, (u_char*)hdr,hdrlen);
#ifdef SLOW_XMIT_COPY
  for (iptr=data,iend=iptr+length-hdrlen,optr=(char *)arcpacket+offset+hdrlen;
       iptr<iend; iptr++,optr++)
    {
      *optr=*iptr;
      /*udelay(5);*/
    }
#else
  memcpy((u_char*)arcpacket+offset+hdrlen, data,length-hdrlen);
#endif

  BUGMSG(D_DURING,"transmitting packet to station %02Xh (%d bytes)\n",
	 daddr,length);

  BUGLVL(D_TX) arcnet_dump_packet(dev,arcpacket->raw,length>MTU,"tx");

  lp->lastload_dest=daddr;
  lp->txready=lp->txbuf;	/* packet is ready for sending */
}