ソースを参照

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,7 +122,7 @@ enum ChipCmdBits {
122 122
     RxOn      = 0x04,
123 123
     TxOff     = 0x02, 
124 124
     TxOn      = 0x01
125
-}
125
+};
126 126
 
127 127
 
128 128
 /* Bits in the RxMode register. */
@@ -163,7 +163,7 @@ enum desc_status_bits {
163 163
 static uint32_t SavedClkRun;	
164 164
 
165 165
 
166
-
166
+/* TODO
167 167
 static const uint8_t rtl_ee_bits[] = {
168 168
 	[SPI_BIT_SCLK]	= EE_SK,
169 169
 	[SPI_BIT_MOSI]	= EE_DI,
@@ -199,7 +199,7 @@ static struct bit_basher_operations rtl_basher_ops = {
199 199
 	.read = rtl_spi_read_bit,
200 200
 	.write = rtl_spi_write_bit,
201 201
 };
202
-
202
+*/
203 203
 /** Portion of EEPROM available for non-volatile stored options
204 204
  *
205 205
  * We use offset 0x40 (i.e. address 0x20), length 0x40.  This block is
@@ -216,16 +216,17 @@ static struct nvo_fragment rtl_nvo_fragments[] = {
216 216
  *
217 217
  * @v NAT		NATSEMI NIC
218 218
  */
219
+/* TODO
219 220
  void rtl_init_eeprom ( struct natsemi_nic *rtl ) {
220 221
 	int ee9356;
221 222
 	int vpd;
222 223
 
223
-	/* Initialise three-wire bus */
224
+	// Initialise three-wire bus 
224 225
 	rtl->spibit.basher.op = &rtl_basher_ops;
225 226
 	rtl->spibit.bus.mode = SPI_MODE_THREEWIRE;
226 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 230
 	ee9356 = ( inw ( rtl->ioaddr + RxConfig ) & Eeprom9356 );
230 231
 	if ( ee9356 ) {
231 232
 		DBG ( "EEPROM is an AT93C56\n" );
@@ -236,7 +237,7 @@ static struct nvo_fragment rtl_nvo_fragments[] = {
236 237
 	}
237 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 241
 	vpd = ( inw ( rtl->ioaddr + Config1 ) & VPDEnable );
241 242
 	if ( vpd ) {
242 243
 		DBG ( "EEPROM in use for VPD; cannot use for options\n" );
@@ -245,7 +246,7 @@ static struct nvo_fragment rtl_nvo_fragments[] = {
245 246
 		rtl->nvo.fragments = rtl_nvo_fragments;
246 247
 	}
247 248
 }
248
-
249
+*/
249 250
 /**
250 251
  * Reset NIC
251 252
  *
@@ -253,11 +254,11 @@ static struct nvo_fragment rtl_nvo_fragments[] = {
253 254
  *
254 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 259
 	int i;
259 260
 	/* Reset chip */
260
-	outb ( ChipReset, nat->ioaddr + ChipCmd );
261
+	outl ( ChipReset, nat->ioaddr + ChipCmd );
261 262
 	mdelay ( 10 );
262 263
 	nat->tx_dirty=0;
263 264
 	nat->tx_cur=0;
@@ -287,6 +288,7 @@ static int nat_open ( struct net_device *netdev ) {
287 288
 	struct natsemi_nic *nat = netdev->priv;
288 289
 	//struct io_buffer *iobuf;
289 290
 	int i;
291
+	uint32_t tx_config,rx_config;
290 292
 	
291 293
 	/* Disable PME:
292 294
         * The PME bit is initialized from the EEPROM contents.
@@ -337,11 +339,11 @@ static int nat_open ( struct net_device *netdev ) {
337 339
 
338 340
 	 /* load Receive Descriptor Register */
339 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 344
 	/* setup Tx ring */
343 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 348
 	/* Enables RX */
347 349
 	outl(RxFilterEnable|AcceptBroadcast|AcceptAllMulticast|AcceptMyPhys, nat->ioaddr+RxFilterAddr);
@@ -375,6 +377,8 @@ static int nat_open ( struct net_device *netdev ) {
375 377
  */
376 378
 static void nat_close ( struct net_device *netdev ) {
377 379
 	struct natsemi_nic *nat = netdev->priv;
380
+	int i;
381
+
378 382
 
379 383
 	/* Reset the hardware to disable everything in one go */
380 384
 	nat_reset ( nat );
@@ -394,7 +398,7 @@ static void nat_close ( struct net_device *netdev ) {
394 398
  * @v iobuf	I/O buffer
395 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 402
 	struct natsemi_nic *nat = netdev->priv;
399 403
 
400 404
        /* check for space in TX ring */
@@ -432,7 +436,7 @@ static int natsemi_transmit ( struct net_device *netdev, struct io_buffer *iobuf
432 436
  */
433 437
 static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
434 438
 	struct natsemi_nic *nat = netdev->priv;
435
-	unsigned int status;
439
+	uint32_t status;
436 440
 	unsigned int rx_status;
437 441
 	unsigned int rx_len;
438 442
 	struct io_buffer *rx_iob;
@@ -442,21 +446,20 @@ static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
442 446
 	/* check the status of packets given to card for transmission */	
443 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 450
 		/* check if current packet has been transmitted or not */
447
-		if(status & own) 
451
+		if(status & OWN) 
448 452
 			break;
449 453
 		/* Check if any errors in transmission */
450 454
 		if (! (status & DescPktOK))
451 455
 		{
452 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 459
 		else
457 460
 		{
458 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 464
 		/* setting cmdsts zero, indicating that it can be reused */
462 465
 		nat->tx[nat->tx_dirty].cmdsts=0;
@@ -464,7 +467,7 @@ static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
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 471
 	/* Handle received packets */
469 472
 	while (rx_quota && (rx_status & OWN))
470 473
 	{
@@ -473,8 +476,8 @@ static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
473 476
 		/*check for the corrupt packet */
474 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 482
 		else
480 483
 		{
@@ -483,7 +486,7 @@ static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
483 486
 				/* leave packet for next call to poll*/
484 487
 				return;
485 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 490
 			/* add to the receive queue. */
488 491
 			netdev_rx(netdev,rx_iob);
489 492
 			rx_quota--;
@@ -494,7 +497,7 @@ static void nat_poll ( struct net_device *netdev, unsigned int rx_quota ) {
494 497
 
495 498
 
496 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,14 +551,14 @@ static int nat_probe ( struct pci_device *pci,
548 551
 
549 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 555
 		DBG("%s: Transceiver default autoneg. %s 10 %s %s duplex.\n",
553 556
 	      	pci->driver_name,
554 557
 	        chip_config & 0x2000 ? "enabled, advertise" : "disabled, force",
555 558
 	        chip_config & 0x4000 ? "0" : "",
556 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
 

読み込み中…
キャンセル
保存