Bladeren bron

added nat_irq to natsemi.c

tags/v0.9.3
Udayan Kumar 18 jaren geleden
bovenliggende
commit
a8c2a4fa11
1 gewijzigde bestanden met toevoegingen van 25 en 22 verwijderingen
  1. 25
    22
      src/drivers/net/natsemi.c

+ 25
- 22
src/drivers/net/natsemi.c Bestand weergeven

371
 		if (!nat->iobuf[i])
371
 		if (!nat->iobuf[i])
372
 			goto memory_alloc_err;
372
 			goto memory_alloc_err;
373
 		nat->rx[i].link   = virt_to_bus((i+1 < NUM_RX_DESC) ? &nat->rx[i+1] : &nat->rx[0]);
373
 		nat->rx[i].link   = virt_to_bus((i+1 < NUM_RX_DESC) ? &nat->rx[i+1] : &nat->rx[0]);
374
-		nat->rx[i].cmdsts = (uint32_t) RX_BUF_SIZE;
374
+		nat->rx[i].cmdsts = RX_BUF_SIZE;
375
 		nat->rx[i].bufptr = virt_to_bus(nat->iobuf[i]->data);
375
 		nat->rx[i].bufptr = virt_to_bus(nat->iobuf[i]->data);
376
 	}
376
 	}
377
 
377
 
410
 	 */
410
 	 */
411
         outl(RxOn, nat->ioaddr + ChipCmd);
411
         outl(RxOn, nat->ioaddr + ChipCmd);
412
 
412
 
413
-	/*enable interrupts
413
+	/* mask the interrupts. note interrupt is not enabled here
414
 	 */
414
 	 */
415
-	outl((RxOk|RxErr|TxOk|TxErr),nat->ioaddr + IntrMask); 
416
-	//outl(1,nat->ioaddr +IntrEnable);
417
 	return 0;
415
 	return 0;
418
 		       
416
 		       
419
 memory_alloc_err:
417
 memory_alloc_err:
421
 	 * if memory for all the buffers is not available
419
 	 * if memory for all the buffers is not available
422
 	 */
420
 	 */
423
 	i=0;
421
 	i=0;
424
-	while(nat->rx[i].cmdsts == (uint32_t) RX_BUF_SIZE) {
422
+	while(nat->rx[i].cmdsts == RX_BUF_SIZE) {
425
 		free_iob(nat->iobuf[i]);
423
 		free_iob(nat->iobuf[i]);
426
 		i++;
424
 		i++;
427
 	}
425
 	}
446
 		
444
 		
447
 		free_iob( nat->iobuf[i] );
445
 		free_iob( nat->iobuf[i] );
448
 	}
446
 	}
449
-	/* disable interrupts
450
-	 */
451
-	//outl(0,nat->ioaddr + IntrMask) ;
452
 }
447
 }
453
 
448
 
454
 /** 
449
 /** 
509
 	struct io_buffer *rx_iob;
504
 	struct io_buffer *rx_iob;
510
 	int i;
505
 	int i;
511
 	
506
 	
512
-	//outl(1,nat->ioaddr +IntrEnable);
513
 	/* read the interrupt register
507
 	/* read the interrupt register
514
 	 */
508
 	 */
515
 	intr_status=inl(nat->ioaddr+IntrStatus);
509
 	intr_status=inl(nat->ioaddr+IntrStatus);
581
 	/* re-enable the potentially idle receive state machine 
575
 	/* re-enable the potentially idle receive state machine 
582
 	 */
576
 	 */
583
 	outl(RxOn, nat->ioaddr + ChipCmd);	
577
 	outl(RxOn, nat->ioaddr + ChipCmd);	
584
-//	outl(1,nat->ioaddr +IntrEnable);
585
 }				
578
 }				
586
 
579
 
587
-/** RTL8139 net device operations */
580
+/**
581
+ * Enable/disable interrupts
582
+ *
583
+ * @v netdev    Network device
584
+ * @v enable    Interrupts should be enabled
585
+ */
586
+static void nat_irq ( struct net_device *netdev, int enable ) {
587
+        struct natsemi_nic *nat= netdev->priv;
588
+
589
+	outl((enable?(RxOk|RxErr|TxOk|TxErr):0),
590
+		nat->ioaddr + IntrMask); 
591
+	outl((enable ? 1:0),nat->ioaddr +IntrEnable);
592
+}
593
+
594
+
595
+
596
+
597
+
598
+/** natsemi net device operations */
588
 static struct net_device_operations nat_operations = {
599
 static struct net_device_operations nat_operations = {
589
         .open           = nat_open,
600
         .open           = nat_open,
590
         .close          = nat_close,
601
         .close          = nat_close,
591
         .transmit       = nat_transmit,
602
         .transmit       = nat_transmit,
592
         .poll           = nat_poll,
603
         .poll           = nat_poll,
604
+	.irq		= nat_irq,
593
 };
605
 };
594
 
606
 
595
 /*
607
 /*
634
 	/* decoding the MAC address read from NVS 
646
 	/* decoding the MAC address read from NVS 
635
 	 * and save it in netdev->ll_addr
647
 	 * and save it in netdev->ll_addr
636
          */
648
          */
637
-	for ( i = 0 ; i < ETH_ALEN ; i+=2 ) {
649
+	for ( i = 0 ; i < ETH_ALEN ; i++) {
638
 		last1=ll_addr_encoded[i]>>7;
650
 		last1=ll_addr_encoded[i]>>7;
639
 	 	netdev->ll_addr[i]=ll_addr_encoded[i]<<1|last;
651
 	 	netdev->ll_addr[i]=ll_addr_encoded[i]<<1|last;
640
-		last=(ll_addr_encoded[i+1]>>7);
641
-		netdev->ll_addr[i+1]=(ll_addr_encoded[i+1]<<1)+last1;
652
+		last=last1;
642
 	}
653
 	}
643
 
654
 
644
 	/* Register network device
655
 	/* Register network device
646
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
657
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
647
 		goto err_register_netdev;
658
 		goto err_register_netdev;
648
 
659
 
649
-	/* Register non-volatile storage 
650
-	 */
651
-	if ( nat->nvo.nvs ) {
652
-		if ( ( rc = nvo_register ( &nat->nvo ) ) != 0 )
653
-			goto err_register_nvo;
654
-	}
655
 	return 0;
660
 	return 0;
656
 
661
 
657
-err_register_nvo:
658
-	unregister_netdev ( netdev );
659
 err_register_netdev:
662
 err_register_netdev:
660
 	/* Disable NIC
663
 	/* Disable NIC
661
 	 */
664
 	 */

Laden…
Annuleren
Opslaan