X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FNetwork%2FNE2000%2Fne2000.c;h=eb3673f291ba4375b79323424b37fb5cc36b03a4;hb=2c3ab58b961dea91fdfbf432a7fdf9593c6e7a8e;hp=3924ba82ae22ce02acaf7b772e04f51a7729e11a;hpb=adbdc45e64c40f7d3a022caedeb22f5e95dcd12a;p=tpg%2Facess2.git diff --git a/Modules/Network/NE2000/ne2000.c b/Modules/Network/NE2000/ne2000.c index 3924ba82..eb3673f2 100644 --- a/Modules/Network/NE2000/ne2000.c +++ b/Modules/Network/NE2000/ne2000.c @@ -3,13 +3,13 @@ * * See: ~/Sources/bochs/bochs.../iodev/ne2k.cc */ -#define DEBUG 0 +#define DEBUG 1 #define VERSION ((0<<8)|50) #include #include #include #include -#include +#include #include // === CONSTANTS === @@ -118,14 +118,15 @@ tCard *gpNe2k_Cards = NULL; int Ne2k_Install(char **Options) { int i, j, k; - int count, id, base; + int count, base; + tPCIDev id; // --- Scan PCI Bus --- // Count Cards giNe2k_CardCount = 0; for( i = 0; i < NUM_COMPAT_DEVICES; i ++ ) { - giNe2k_CardCount += PCI_CountDevices( csaCOMPAT_DEVICES[i].Vendor, csaCOMPAT_DEVICES[i].Device, 0 ); + giNe2k_CardCount += PCI_CountDevices( csaCOMPAT_DEVICES[i].Vendor, csaCOMPAT_DEVICES[i].Device ); } if( giNe2k_CardCount == 0 ) { @@ -139,12 +140,12 @@ int Ne2k_Install(char **Options) for( i = 0; i < NUM_COMPAT_DEVICES; i ++ ) { - count = PCI_CountDevices( csaCOMPAT_DEVICES[i].Vendor, csaCOMPAT_DEVICES[i].Device, 0 ); + count = PCI_CountDevices( csaCOMPAT_DEVICES[i].Vendor, csaCOMPAT_DEVICES[i].Device ); for( j = 0; j < count; j ++,k ++ ) { - id = PCI_GetDevice( csaCOMPAT_DEVICES[i].Vendor, csaCOMPAT_DEVICES[i].Device, 0, j ); + id = PCI_GetDevice( csaCOMPAT_DEVICES[i].Vendor, csaCOMPAT_DEVICES[i].Device, j ); // Create Structure - base = PCI_AssignPort( id, 0, 0x20 ); + base = PCI_GetBAR( id, 0 ); gpNe2k_Cards[ k ].IOBase = base; gpNe2k_Cards[ k ].IRQ = PCI_GetIRQ( id ); gpNe2k_Cards[ k ].NextMemPage = 64; @@ -289,6 +290,8 @@ Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer); + // TODO: Lock + // Sanity Check Length if(Length > TX_BUF_SIZE*256) { Log_Warning( @@ -360,7 +363,11 @@ Uint64 Ne2k_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer); // Wait for packets - Semaphore_Wait( &Card->Semaphore, 1 ); + if( Semaphore_Wait( &Card->Semaphore, 1 ) != 1 ) + { + // Error or interrupted + LEAVE_RET('i', 0); + } outb(Card->IOBase, 0x22 | (1 << 6)); // Page 6 LOG("CURR : 0x%02x", inb(Card->IOBase + CURR)); @@ -392,10 +399,7 @@ Uint64 Ne2k_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) LOG("pktHdr->Length (%i) > 256 - 4, allocated buffer %p", pktHdr->Length, buf); - if(!buf) { - LEAVE('i', -1); - return -1; - } + if(!buf) LEAVE_RET('i', -1); // Copy the already read data memcpy(buf, data, 256); @@ -523,7 +527,9 @@ void Ne2k_IRQHandler(int IntNum) { //if( gpNe2k_Cards[i].NumWaitingPackets > MAX_PACKET_QUEUE ) // gpNe2k_Cards[i].NumWaitingPackets = MAX_PACKET_QUEUE; - Semaphore_Signal( &gpNe2k_Cards[i].Semaphore, 1 ); + if( Semaphore_Signal( &gpNe2k_Cards[i].Semaphore, 1 ) != 1 ) { + // Oops? + } } // 1: Packet sent (no error) // 2: Recieved with error