X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FNetwork%2FNE2000%2Fne2000.c;h=d77bfb8694341420bc8960cf5451339339e6bb92;hb=15999a03acd4083fb2618c92bebbc557813c5084;hp=76e4379f64b0145b75b5e0dc3b19bc6825d78bf6;hpb=0dbc91f0676576b954aa95dafdb434ce19bc805c;p=tpg%2Facess2.git diff --git a/Modules/Network/NE2000/ne2000.c b/Modules/Network/NE2000/ne2000.c index 76e4379f..d77bfb86 100644 --- a/Modules/Network/NE2000/ne2000.c +++ b/Modules/Network/NE2000/ne2000.c @@ -29,7 +29,7 @@ static const struct { {0x10EC, 0x8029}, // Realtek 8029 {0x10EC, 0x8129} // Realtek 8129 }; -#define NUM_COMPAT_DEVICES (sizeof(csaCOMPAT_DEVICES)/sizeof(csaCOMPAT_DEVICES[0])) +#define NUM_COMPAT_DEVICES ((int)(sizeof(csaCOMPAT_DEVICES)/sizeof(csaCOMPAT_DEVICES[0]))) enum eNe2k_Page0Read { CMD = 0, //!< the master command register @@ -75,7 +75,7 @@ typedef struct sNe2k_Card { int NextMemPage; //!< Next Card Memory page to use - Uint8 Buffer[RX_BUF_SIZE]; + Uint8 Buffer[RX_BUF_SIZE*256]; char Name[2]; // "0" tVFS_Node Node; @@ -85,7 +85,7 @@ typedef struct sNe2k_Card { // === PROTOTYPES === int Ne2k_Install(char **Arguments); char *Ne2k_ReadDir(tVFS_Node *Node, int Pos); -tVFS_Node *Ne2k_FindDir(tVFS_Node *Node, char *Name); +tVFS_Node *Ne2k_FindDir(tVFS_Node *Node, const char *Name); int Ne2k_IOCtl(tVFS_Node *Node, int ID, void *Data); Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); Uint64 Ne2k_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); @@ -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 ) { + Log_Warning("Ne2k", "No cards detected"); + return MODULE_ERR_NOTNEEDED; + } + // Enumerate Cards k = 0; gpNe2k_Cards = calloc( giNe2k_CardCount, sizeof(tCard) ); @@ -157,7 +162,7 @@ int Ne2k_Install(char **Options) outb( base + CURR, RX_FIRST ); // Current RX page outb( base + CMD, 0x21 ); // No DMA and Stop outb( base + DCR, 0x49 ); // Set WORD mode - outb( base + IMR, 0x00 ); + outb( base + IMR, 0x00 ); // Interrupt Mask Register outb( base + ISR, 0xFF ); outb( base + RCR, 0x20 ); // Reciever to Monitor outb( base + TCR, 0x02 ); // Transmitter OFF (TCR.LB = 1, Internal Loopback) @@ -194,12 +199,11 @@ int Ne2k_Install(char **Options) Ne2k_WriteReg(base, MAC5, 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", - 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_Log("Ne2k", "Card %i 0x%04x IRQ%i %02x:%02x:%02x:%02x:%02x:%02x", + k, base, gpNe2k_Cards[ k ].IRQ, + 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] ); // Set VFS Node @@ -216,7 +220,7 @@ int Ne2k_Install(char **Options) gNe2k_DriverInfo.RootNode.Size = giNe2k_CardCount; DevFS_AddDevice( &gNe2k_DriverInfo ); - return 1; + return MODULE_ERR_OK; } /** @@ -232,9 +236,9 @@ char *Ne2k_ReadDir(tVFS_Node *Node, int Pos) } /** - * \fn tVFS_Node *Ne2k_FindDir(tVFS_Node *Node, char *Name) + * \fn tVFS_Node *Ne2k_FindDir(tVFS_Node *Node, const char *Name) */ -tVFS_Node *Ne2k_FindDir(tVFS_Node *Node, char *Name) +tVFS_Node *Ne2k_FindDir(tVFS_Node *Node, const char *Name) { if(Name[0] == '\0' || Name[1] != '\0') return NULL; @@ -302,11 +306,17 @@ Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) tCard *Card = (tCard*)Node->ImplPtr; Uint16 *buf = Buffer; int rem = Length; + int page; ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer); // Sanity Check Length - if(Length > TX_BUF_SIZE) { + if(Length > TX_BUF_SIZE*256) { + Log_Warning( + "Ne2k", + "Ne2k_Write - Attempting to send over TX_BUF_SIZE*256 (%i) bytes (%i)", + TX_BUF_SIZE*256, Length + ); LEAVE('i', 0); return 0; } @@ -327,14 +337,16 @@ Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) // Set up transfer outb(Card->IOBase + RSAR0, 0x00); // Page Offset - outb(Card->IOBase + RSAR1, Ne2k_int_GetWritePage(Card, Length)); // Page Offset + page = Ne2k_int_GetWritePage(Card, Length); + outb(Card->IOBase + RSAR1, page); // Page Offset // Start //outb(Card->IOBase + CMD, 0|0x18|0x4|0x2); // Page 0, Transmit Packet, TXP, Start 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(); @@ -342,6 +354,7 @@ Uint64 Ne2k_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) outb( Card->IOBase + ISR, 0x40 ); // ACK Interrupt // Send Packet + outb(Card->IOBase + TPSR, page); outb(Card->IOBase + CMD, 0|0x10|0x4|0x2); // Complete DMA @@ -498,5 +511,5 @@ void Ne2k_IRQHandler(int IntNum) return ; } } - Warning("[NE2K ] Recieved Unknown IRQ %i", IntNum); + Log_Warning("Ne2k", "Recieved Unknown IRQ %i", IntNum); }