瀏覽代碼

debugging natsemi.c

tags/v0.9.3
Udayan Kumar 17 年之前
父節點
當前提交
623d10c66f
共有 3 個檔案被更改,包括 51 行新增28 行删除
  1. 1
    1
      src/config.h
  2. 6
    1
      src/drivers/bitbash/spi_bit.c
  3. 44
    26
      src/drivers/net/natsemi.c

+ 1
- 1
src/config.h 查看文件

@@ -18,7 +18,7 @@
18 18
  */
19 19
 
20 20
 #define	CONSOLE_FIRMWARE	/* Default BIOS console */
21
-#undef	CONSOLE_SERIAL		/* Serial port */
21
+#define	CONSOLE_SERIAL		/* Serial port */
22 22
 #undef	CONSOLE_DIRECT_VGA	/* Direct access to VGA card */
23 23
 #undef	CONSOLE_BTEXT		/* Who knows what this does? */
24 24
 #undef	CONSOLE_PC_KBD		/* Direct access to PC keyboard */

+ 6
- 1
src/drivers/bitbash/spi_bit.c 查看文件

@@ -96,13 +96,18 @@ static void spi_bit_transfer ( struct spi_bit_basher *spibit,
96 96
 
97 97
 	DBG ( "Transferring %d bits in mode %x\n", len, bus->mode );
98 98
 
99
+<<<<<<< HEAD:src/drivers/bitbash/spi_bit.c
99 100
 	for ( step = 0 ; step < ( len * 2 ) ; step++ ) {
100 101
 		/* Calculate byte offset and byte mask */
101 102
 		bit_offset = ( ( endianness == SPI_BIT_BIG_ENDIAN ) ?
102 103
 			       ( len - ( step / 2 ) - 1 ) : ( step / 2 ) );
103 104
 		byte_offset = ( bit_offset / 8 );
104 105
 		byte_mask = ( 1 << ( bit_offset % 8 ) );
105
-
106
+=======
107
+>>>>>>> debugging natsemi.c:src/drivers/bitbash/spi_bit.c
108
+<<<<<<< HEAD:src/drivers/bitbash/spi_bit.c
109
+=======
110
+>>>>>>> debugging natsemi.c:src/drivers/bitbash/spi_bit.c
106 111
 		/* Shift data in or out */
107 112
 		if ( sclk == cpha ) {
108 113
 			const uint8_t *byte;

+ 44
- 26
src/drivers/net/natsemi.c 查看文件

@@ -205,7 +205,7 @@ static struct bit_basher_operations nat_basher_ops = {
205 205
  * detect that the card is not supporting VPD.
206 206
  */
207 207
 static struct nvo_fragment nat_nvo_fragments[] = {
208
-	{ 0x20, 0x40 },
208
+	{ 0x0f, 0x40 },
209 209
 	{ 0, 0 }
210 210
 };
211 211
 
@@ -232,8 +232,8 @@ static struct nvo_fragment nat_nvo_fragments[] = {
232 232
 	//if ( vpd ) {
233 233
 	//	DBG ( "EEPROM in use for VPD; cannot use for options\n" );
234 234
 	//} else {
235
-//		nat->nvo.nvs = &nat->eeprom.nvs;
236
-//		nat->nvo.fragments = nat_nvo_fragments;
235
+		nat->nvo.nvs = &nat->eeprom.nvs;
236
+		nat->nvo.fragments = nat_nvo_fragments;
237 237
 //	}
238 238
 }
239 239
 
@@ -293,12 +293,22 @@ static int nat_open ( struct net_device *netdev ) {
293 293
 
294 294
 
295 295
 	/* Program the MAC address TODO enable this comment */
296
-	
296
+	 uint8_t last=0;
297
+	 uint8_t last1=0;
297 298
 	 for ( i = 0 ; i < ETH_ALEN ; i+=2 )
298 299
 	 {
300
+	//	DBG("MAC address %d octet :%X %X\n",i,netdev->ll_addr[i],netdev->ll_addr[i+1]);
301
+	//	DBG("LAst = %d last1 = %d\n",last,last1);
299 302
 		outl(i,nat->ioaddr+RxFilterAddr);
303
+		last1=netdev->ll_addr[i]>>7;
304
+	 	netdev->ll_addr[i]=netdev->ll_addr[i]<<1|last;
305
+		last=(netdev->ll_addr[i+1]>>7);
306
+		netdev->ll_addr[i+1]=(netdev->ll_addr[i+1]<<1)+last1;
307
+
300 308
 		outw ( netdev->ll_addr[i] + (netdev->ll_addr[i+1]<<8), nat->ioaddr +RxFilterData);
301
-		DBG("MAC address %d octet :%X %X\n",i,netdev->ll_addr[i],netdev->ll_addr[i+1]);
309
+		//outw ( (fullbyte>>8)+(fullbyte<<8), nat->ioaddr +RxFilterData);
310
+	//	DBG("MAC address %d octet :%X %X\n",i,netdev->ll_addr[i],netdev->ll_addr[i+1]);
311
+	//	DBG("LAst = %d last1 = %d\n",last,last1);
302 312
 	}
303 313
        
304 314
 
@@ -403,17 +413,20 @@ static int nat_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
403 413
 		return -ENOBUFS;
404 414
 	}
405 415
 
416
+	//DBG_HD(iobuf->data,iob_len(iobuf));
406 417
 
407 418
 	/* Pad and align packet */
408 419
 	iob_pad ( iobuf, ETH_ZLEN );
409 420
 
410 421
 	/* Add to TX ring */
411 422
 	DBG ( "TX id %d at %lx+%x\n", nat->tx_cur,
412
-	      virt_to_bus ( iobuf->data ), iob_len ( iobuf ) );
423
+	      virt_to_bus ( &iobuf->data ), iob_len ( iobuf ) );
413 424
 
414 425
 	nat->tx[nat->tx_cur].bufptr = virt_to_bus(iobuf->data);
415 426
 	nat->tx[nat->tx_cur].cmdsts= (uint32_t) iob_len(iobuf)|OWN;
416 427
 
428
+
429
+	//DBG_HD(bus_to_virt(nat->tx[nat->tx_cur].bufptr), iob_len(iobuf) );
417 430
 	nat->tx_cur=(nat->tx_cur+1) % TX_RING_SIZE;
418 431
 
419 432
 	/*start the transmitter  */
@@ -430,40 +443,46 @@ static int nat_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
430 443
  */
431 444
 static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
432 445
 	struct natsemi_nic *nat = netdev->priv;
433
-	uint32_t status;
446
+	unsigned int status;
434 447
 	unsigned int rx_status;
435 448
 	unsigned int rx_len;
436 449
 	struct io_buffer *rx_iob;
437 450
 	int i;
438
-
439 451
 	
440 452
 	/* check the status of packets given to card for transmission */	
441
-	for ( i = 0 ; i < TX_RING_SIZE ; i++ ) 
453
+	i=nat->tx_dirty;
454
+	while(i!=nat->tx_cur)
442 455
 	{
443 456
 		//status=(uint32_t)bus_to_virt(nat->tx[nat->tx_dirty].cmdsts);
444
-		status=(uint32_t)nat->tx[nat->tx_dirty].cmdsts;
457
+		status=nat->tx[nat->tx_dirty].cmdsts;
458
+		DBG("value of tx_dirty = %d tx_cur=%d status=%X\n",
459
+			nat->tx_dirty,nat->tx_cur,status);
460
+		
445 461
 		/* check if current packet has been transmitted or not */
446 462
 		if(status & OWN) 
447 463
 			break;
448 464
 		/* Check if any errors in transmission */
449 465
 		if (! (status & DescPktOK))
450 466
 		{
451
-			printf("Error in sending Packet with data: %s\n and status:%X\n",
452
-					(char *)nat->tx[nat->tx_dirty].bufptr,(unsigned int)status);
467
+			printf("Error in sending Packet status:%X\n",
468
+					(unsigned int)status);
453 469
 		}
454 470
 		else
455 471
 		{
456
-			DBG("Success in transmitting Packet with data: %s",
457
-				(char *)nat->tx[nat->tx_dirty].bufptr);
472
+			DBG("Success in transmitting Packet with data\n");
473
+		//	DBG_HD(&nat->tx[nat->tx_dirty].bufptr,130);
458 474
 		}
459 475
 		/* setting cmdsts zero, indicating that it can be reused */
460 476
 		nat->tx[nat->tx_dirty].cmdsts=0;
461 477
 		nat->tx_dirty=(nat->tx_dirty +1) % TX_RING_SIZE;
478
+		i=(i+1) % TX_RING_SIZE;
479
+
462 480
 	}
463 481
 			
464 482
 	
465 483
 	//rx_status=(unsigned int)bus_to_virt(nat->rx[nat->rx_cur].cmdsts); 
466 484
 	rx_status=(unsigned int)nat->rx[nat->rx_cur].cmdsts; 
485
+	//DBG ("Receiver Status = %x\n",rx_status);
467 486
 	/* Handle received packets */
468 487
 	while (rx_quota && (rx_status & OWN))
469 488
 	{
@@ -483,7 +502,10 @@ static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
483 502
 				/* leave packet for next call to poll*/
484 503
 				return;
485 504
 			memcpy(iob_put(rx_iob,rx_len),
486
-					nat->rx[nat->rx_cur].bufptr,rx_len);
505
+					bus_to_virt(nat->rx[nat->rx_cur].bufptr),rx_len);
506
+			//DBG_HD(bus_to_virt(nat->rx[nat->rx_cur].bufptr),rx_len);
507
+
508
+			DBG("received packet");
487 509
 			/* add to the receive queue. */
488 510
 			netdev_rx(netdev,rx_iob);
489 511
 			rx_quota--;
@@ -538,14 +560,10 @@ static int nat_probe ( struct pci_device *pci,
538 560
 	nat_reset ( nat );
539 561
 	nat_init_eeprom ( nat );
540 562
 	nvs_read ( &nat->eeprom.nvs, EE_MAC, netdev->ll_addr, ETH_ALEN );
541
-	uint8_t  eetest[12];	
563
+	uint8_t  eetest[128];	
542 564
 	int i;
543
-	nvs_read ( &nat->eeprom.nvs, 6, eetest,8 );
544
-	for (i=0;i<8;i++)
545
-	{
546
-		printf("%d word : %X\n",i,eetest[i]);
547
-	}
548
-		
565
+	nvs_read ( &nat->eeprom.nvs, 0, eetest,128 );
566
+	//	DBG_HD(&eetest,128);
549 567
 	
550 568
 
551 569
 	/* mdio routine of etherboot-5.4.0 natsemi driver has been removed and 
@@ -580,12 +598,12 @@ static int nat_probe ( struct pci_device *pci,
580 598
 
581 599
 	/* Register non-volatile storagei
582 600
 	 * uncomment lines below in final version*/
583
-	/*
584
-	 if ( rtl->nvo.nvs ) {
585
-		if ( ( rc = nvo_register ( &rtl->nvo ) ) != 0 )
601
+	
602
+	 if ( nat->nvo.nvs ) {
603
+		if ( ( rc = nvo_register ( &nat->nvo ) ) != 0 )
586 604
 			goto err;
587 605
 	}
588
-	*/
606
+	
589 607
 
590 608
 	return 0;
591 609
 

Loading…
取消
儲存