Misc Changes, Added Logging Subsystem, Fixes to InitRD, Working on RTL8139 driver
[tpg/acess2.git] / Modules / Network / NE2000 / ne2000.c
index 24d8278..60f9ac2 100644 (file)
@@ -127,6 +127,11 @@ int Ne2k_Install(char **Options)
                giNe2k_CardCount += PCI_CountDevices( csaCOMPAT_DEVICES[i].Vendor, csaCOMPAT_DEVICES[i].Device, 0 );
        }
        
+       if( giNe2k_CardCount == 0 ) {
+               Warning("[Ne2k ] No cards detected");
+               return MODULE_ERR_NOTNEEDED;
+       }
+       
        // Enumerate Cards
        k = 0;
        gpNe2k_Cards = calloc( giNe2k_CardCount, sizeof(tCard) );
@@ -194,6 +199,13 @@ int Ne2k_Install(char **Options)
                        Ne2k_WriteReg(base, MAC5, gpNe2k_Cards[ k ].MacAddr[5]);
                        */
                        
+                       Log_Log("NE2K", "Card %i 0x%04x %02x:%02x:%02x:%02x:%02x:%02x",
+                               k, base,
+                               gpNe2k_Cards[k].MacAddr[0], gpNe2k_Cards[k].MacAddr[1],
+                               gpNe2k_Cards[k].MacAddr[2], gpNe2k_Cards[k].MacAddr[3],
+                               gpNe2k_Cards[k].MacAddr[4], gpNe2k_Cards[k].MacAddr[5]
+                               );
+                       
                        Log("[NE2K]: Card #%i: IRQ=%i, IOBase=0x%x",
                                k, gpNe2k_Cards[ k ].IRQ, gpNe2k_Cards[ k ].IOBase);
                        Log("MAC Address %x:%x:%x:%x:%x:%x",
@@ -216,7 +228,7 @@ int Ne2k_Install(char **Options)
        
        gNe2k_DriverInfo.RootNode.Size = giNe2k_CardCount;
        DevFS_AddDevice( &gNe2k_DriverInfo );
-       return 1;
+       return MODULE_ERR_OK;
 }
 
 /**
@@ -309,7 +321,7 @@ Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
        // Sanity Check Length
        if(Length > TX_BUF_SIZE*256) {
                Warning(
-                       "Ne2k_Write - Attempting to send over TX_BUF_SIZE(%i) bytes (%i)",
+                       "Ne2k_Write - Attempting to send over TX_BUF_SIZE*256 (%i) bytes (%i)",
                        TX_BUF_SIZE*256, Length
                        );
                LEAVE('i', 0);
@@ -339,8 +351,9 @@ Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
        outb(Card->IOBase + CMD, 0|0x10|0x2);   // Page 0, Remote Write, Start
        
        // Send Data
-       for(rem = Length; rem; rem -= 2)
+       for(rem = Length; rem > 0; rem -= 2) {
                outw(Card->IOBase + 0x10, *buf++);
+       }
        
        while( inb(Card->IOBase + ISR) == 0 )   // Wait for Remote DMA Complete
                ;       //Proc_Yield();

UCC git Repository :: git.ucc.asn.au