소스 검색

same as before, but now compiling natsemi

tags/v0.9.3
Udayan Kumar 18 년 전
부모
커밋
99c680f743
1개의 변경된 파일28개의 추가작업 그리고 25개의 파일을 삭제
  1. 28
    25
      src/drivers/net/natsemi.c

+ 28
- 25
src/drivers/net/natsemi.c 파일 보기

122
     RxOn      = 0x04,
122
     RxOn      = 0x04,
123
     TxOff     = 0x02, 
123
     TxOff     = 0x02, 
124
     TxOn      = 0x01
124
     TxOn      = 0x01
125
-}
125
+};
126
 
126
 
127
 
127
 
128
 /* Bits in the RxMode register. */
128
 /* Bits in the RxMode register. */
163
 static uint32_t SavedClkRun;	
163
 static uint32_t SavedClkRun;	
164
 
164
 
165
 
165
 
166
-
166
+/* TODO
167
 static const uint8_t rtl_ee_bits[] = {
167
 static const uint8_t rtl_ee_bits[] = {
168
 	[SPI_BIT_SCLK]	= EE_SK,
168
 	[SPI_BIT_SCLK]	= EE_SK,
169
 	[SPI_BIT_MOSI]	= EE_DI,
169
 	[SPI_BIT_MOSI]	= EE_DI,
199
 	.read = rtl_spi_read_bit,
199
 	.read = rtl_spi_read_bit,
200
 	.write = rtl_spi_write_bit,
200
 	.write = rtl_spi_write_bit,
201
 };
201
 };
202
-
202
+*/
203
 /** Portion of EEPROM available for non-volatile stored options
203
 /** Portion of EEPROM available for non-volatile stored options
204
  *
204
  *
205
  * We use offset 0x40 (i.e. address 0x20), length 0x40.  This block is
205
  * We use offset 0x40 (i.e. address 0x20), length 0x40.  This block is
216
  *
216
  *
217
  * @v NAT		NATSEMI NIC
217
  * @v NAT		NATSEMI NIC
218
  */
218
  */
219
+/* TODO
219
  void rtl_init_eeprom ( struct natsemi_nic *rtl ) {
220
  void rtl_init_eeprom ( struct natsemi_nic *rtl ) {
220
 	int ee9356;
221
 	int ee9356;
221
 	int vpd;
222
 	int vpd;
222
 
223
 
223
-	/* Initialise three-wire bus */
224
+	// Initialise three-wire bus 
224
 	rtl->spibit.basher.op = &rtl_basher_ops;
225
 	rtl->spibit.basher.op = &rtl_basher_ops;
225
 	rtl->spibit.bus.mode = SPI_MODE_THREEWIRE;
226
 	rtl->spibit.bus.mode = SPI_MODE_THREEWIRE;
226
 	init_spi_bit_basher ( &rtl->spibit );
227
 	init_spi_bit_basher ( &rtl->spibit );
227
 
228
 
228
-	/* Detect EEPROM type and initialise three-wire device */
229
+	//Detect EEPROM type and initialise three-wire device 
229
 	ee9356 = ( inw ( rtl->ioaddr + RxConfig ) & Eeprom9356 );
230
 	ee9356 = ( inw ( rtl->ioaddr + RxConfig ) & Eeprom9356 );
230
 	if ( ee9356 ) {
231
 	if ( ee9356 ) {
231
 		DBG ( "EEPROM is an AT93C56\n" );
232
 		DBG ( "EEPROM is an AT93C56\n" );
236
 	}
237
 	}
237
 	rtl->eeprom.bus = &rtl->spibit.bus;
238
 	rtl->eeprom.bus = &rtl->spibit.bus;
238
 
239
 
239
-	/* Initialise space for non-volatile options, if available */
240
+	// Initialise space for non-volatile options, if available 
240
 	vpd = ( inw ( rtl->ioaddr + Config1 ) & VPDEnable );
241
 	vpd = ( inw ( rtl->ioaddr + Config1 ) & VPDEnable );
241
 	if ( vpd ) {
242
 	if ( vpd ) {
242
 		DBG ( "EEPROM in use for VPD; cannot use for options\n" );
243
 		DBG ( "EEPROM in use for VPD; cannot use for options\n" );
245
 		rtl->nvo.fragments = rtl_nvo_fragments;
246
 		rtl->nvo.fragments = rtl_nvo_fragments;
246
 	}
247
 	}
247
 }
248
 }
248
-
249
+*/
249
 /**
250
 /**
250
  * Reset NIC
251
  * Reset NIC
251
  *
252
  *
253
  *
254
  *
254
  * Issues a hardware reset and waits for the reset to complete.
255
  * Issues a hardware reset and waits for the reset to complete.
255
  */
256
  */
256
-static void nat_reset ( struct nat_nic *nat ) {
257
+static void nat_reset ( struct natsemi_nic *nat ) {
257
 
258
 
258
 	int i;
259
 	int i;
259
 	/* Reset chip */
260
 	/* Reset chip */
260
-	outb ( ChipReset, nat->ioaddr + ChipCmd );
261
+	outl ( ChipReset, nat->ioaddr + ChipCmd );
261
 	mdelay ( 10 );
262
 	mdelay ( 10 );
262
 	nat->tx_dirty=0;
263
 	nat->tx_dirty=0;
263
 	nat->tx_cur=0;
264
 	nat->tx_cur=0;
287
 	struct natsemi_nic *nat = netdev->priv;
288
 	struct natsemi_nic *nat = netdev->priv;
288
 	//struct io_buffer *iobuf;
289
 	//struct io_buffer *iobuf;
289
 	int i;
290
 	int i;
291
+	uint32_t tx_config,rx_config;
290
 	
292
 	
291
 	/* Disable PME:
293
 	/* Disable PME:
292
         * The PME bit is initialized from the EEPROM contents.
294
         * The PME bit is initialized from the EEPROM contents.
337
 
339
 
338
 	 /* load Receive Descriptor Register */
340
 	 /* load Receive Descriptor Register */
339
 	outl(virt_to_bus(&nat->rx[0]), nat->ioaddr + RxRingPtr);
341
 	outl(virt_to_bus(&nat->rx[0]), nat->ioaddr + RxRingPtr);
340
-	DBG("Natsemi Rx descriptor loaded with: %X\n",inl(nat->ioaddr+RingPtr));		
342
+	DBG("Natsemi Rx descriptor loaded with: %X\n",(unsigned int)inl(nat->ioaddr+RxRingPtr));		
341
 
343
 
342
 	/* setup Tx ring */
344
 	/* setup Tx ring */
343
 	outl(virt_to_bus(&nat->tx[0]),nat->ioaddr+TxRingPtr);
345
 	outl(virt_to_bus(&nat->tx[0]),nat->ioaddr+TxRingPtr);
344
-	DBG("Natsemi Tx descriptor loaded with: %X\n",inl(nat->ioaddr+TxRingPtr));
346
+	DBG("Natsemi Tx descriptor loaded with: %X\n",(unsigned int)inl(nat->ioaddr+TxRingPtr));
345
 
347
 
346
 	/* Enables RX */
348
 	/* Enables RX */
347
 	outl(RxFilterEnable|AcceptBroadcast|AcceptAllMulticast|AcceptMyPhys, nat->ioaddr+RxFilterAddr);
349
 	outl(RxFilterEnable|AcceptBroadcast|AcceptAllMulticast|AcceptMyPhys, nat->ioaddr+RxFilterAddr);
375
  */
377
  */
376
 static void nat_close ( struct net_device *netdev ) {
378
 static void nat_close ( struct net_device *netdev ) {
377
 	struct natsemi_nic *nat = netdev->priv;
379
 	struct natsemi_nic *nat = netdev->priv;
380
+	int i;
381
+
378
 
382
 
379
 	/* Reset the hardware to disable everything in one go */
383
 	/* Reset the hardware to disable everything in one go */
380
 	nat_reset ( nat );
384
 	nat_reset ( nat );
394
  * @v iobuf	I/O buffer
398
  * @v iobuf	I/O buffer
395
  * @ret rc	Return status code
399
  * @ret rc	Return status code
396
  */
400
  */
397
-static int natsemi_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
401
+static int nat_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
398
 	struct natsemi_nic *nat = netdev->priv;
402
 	struct natsemi_nic *nat = netdev->priv;
399
 
403
 
400
        /* check for space in TX ring */
404
        /* check for space in TX ring */
432
  */
436
  */
433
 static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
437
 static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
434
 	struct natsemi_nic *nat = netdev->priv;
438
 	struct natsemi_nic *nat = netdev->priv;
435
-	unsigned int status;
439
+	uint32_t status;
436
 	unsigned int rx_status;
440
 	unsigned int rx_status;
437
 	unsigned int rx_len;
441
 	unsigned int rx_len;
438
 	struct io_buffer *rx_iob;
442
 	struct io_buffer *rx_iob;
442
 	/* check the status of packets given to card for transmission */	
446
 	/* check the status of packets given to card for transmission */	
443
 	for ( i = 0 ; i < TX_RING_SIZE ; i++ ) 
447
 	for ( i = 0 ; i < TX_RING_SIZE ; i++ ) 
444
 	{
448
 	{
445
-		status=bus_to_virt(nat->tx[nat->tx_dirty].cmdsts);
449
+		status=(uint32_t)bus_to_virt(nat->tx[nat->tx_dirty].cmdsts);
446
 		/* check if current packet has been transmitted or not */
450
 		/* check if current packet has been transmitted or not */
447
-		if(status & own) 
451
+		if(status & OWN) 
448
 			break;
452
 			break;
449
 		/* Check if any errors in transmission */
453
 		/* Check if any errors in transmission */
450
 		if (! (status & DescPktOK))
454
 		if (! (status & DescPktOK))
451
 		{
455
 		{
452
 			printf("Error in sending Packet with data: %s\n and status:%X\n",
456
 			printf("Error in sending Packet with data: %s\n and status:%X\n",
453
-					bus_to_virt(nat->tx[nat->tx_dirty].bufptr),
454
-					status);
457
+					(char *)bus_to_virt(nat->tx[nat->tx_dirty].bufptr),(unsigned int)status);
455
 		}
458
 		}
456
 		else
459
 		else
457
 		{
460
 		{
458
 			DBG("Success in transmitting Packet with data: %s",
461
 			DBG("Success in transmitting Packet with data: %s",
459
-					bus_to_virt(nat->tx[nat->tx_dirty].bufptr));
462
+				(char *)bus_to_virt(nat->tx[nat->tx_dirty].bufptr));
460
 		}
463
 		}
461
 		/* setting cmdsts zero, indicating that it can be reused */
464
 		/* setting cmdsts zero, indicating that it can be reused */
462
 		nat->tx[nat->tx_dirty].cmdsts=0;
465
 		nat->tx[nat->tx_dirty].cmdsts=0;
464
 	}
467
 	}
465
 			
468
 			
466
 	
469
 	
467
-	rx_status=bus_to_virt(nat->rx[nat->rx_cur].cmdsts); 
470
+	rx_status=(unsigned int)bus_to_virt(nat->rx[nat->rx_cur].cmdsts); 
468
 	/* Handle received packets */
471
 	/* Handle received packets */
469
 	while (rx_quota && (rx_status & OWN))
472
 	while (rx_quota && (rx_status & OWN))
470
 	{
473
 	{
473
 		/*check for the corrupt packet */
476
 		/*check for the corrupt packet */
474
 		if((rx_status & (DescMore|DescPktOK|RxTooLong)) != DescPktOK)
477
 		if((rx_status & (DescMore|DescPktOK|RxTooLong)) != DescPktOK)
475
 		{
478
 		{
476
-			 printf("natsemi_poll: Corrupted packet received, 
477
-					 buffer status = %X\n",rx_status);
479
+			 printf("natsemi_poll: Corrupted packet received, "
480
+					"buffer status = %X\n",rx_status);
478
 		}
481
 		}
479
 		else
482
 		else
480
 		{
483
 		{
483
 				/* leave packet for next call to poll*/
486
 				/* leave packet for next call to poll*/
484
 				return;
487
 				return;
485
 			memcpy(iob_put(rx_iob,rx_len),
488
 			memcpy(iob_put(rx_iob,rx_len),
486
-					nat->rx[nat->rx_cur].bufptr,rxlen);
489
+					nat->rx[nat->rx_cur].bufptr,rx_len);
487
 			/* add to the receive queue. */
490
 			/* add to the receive queue. */
488
 			netdev_rx(netdev,rx_iob);
491
 			netdev_rx(netdev,rx_iob);
489
 			rx_quota--;
492
 			rx_quota--;
494
 
497
 
495
 
498
 
496
 	 /* re-enable the potentially idle receive state machine */
499
 	 /* re-enable the potentially idle receive state machine */
497
-	    outl(RxOn, ioaddr + ChipCmd);	
500
+	    outl(RxOn, nat->ioaddr + ChipCmd);	
498
 }				
501
 }				
499
 
502
 
500
 
503
 
548
 
551
 
549
         advertising = inl(nat->ioaddr + 0x80 + (4<<2)) & 0xffff; 
552
         advertising = inl(nat->ioaddr + 0x80 + (4<<2)) & 0xffff; 
550
         {
553
         {
551
-	   	uint32_t chip_config = inl(ioaddr + ChipConfig);
554
+	   	uint32_t chip_config = inl(nat->ioaddr + ChipConfig);
552
 		DBG("%s: Transceiver default autoneg. %s 10 %s %s duplex.\n",
555
 		DBG("%s: Transceiver default autoneg. %s 10 %s %s duplex.\n",
553
 	      	pci->driver_name,
556
 	      	pci->driver_name,
554
 	        chip_config & 0x2000 ? "enabled, advertise" : "disabled, force",
557
 	        chip_config & 0x2000 ? "enabled, advertise" : "disabled, force",
555
 	        chip_config & 0x4000 ? "0" : "",
558
 	        chip_config & 0x4000 ? "0" : "",
556
 	        chip_config & 0x8000 ? "full" : "half");
559
 	        chip_config & 0x8000 ? "full" : "half");
557
     	}
560
     	}
558
-	DBG("%s: Transceiver status %hX advertising %hX\n",pci->driver_name, (int)inl(nat->ioaddr + 0x84), advertising);
561
+	DBG("%s: Transceiver status %hX advertising %hX\n",pci->driver_name, (int)inl(nat->ioaddr + 0x84),(unsigned int) advertising);
559
 
562
 
560
 
563
 
561
 
564
 

Loading…
취소
저장