From: Peter Kamm Date: Thu, 31 Jul 2008 16:58:24 +0000 (+0000) Subject: Version that automatically checks RX packet size. Still receives multiple instances... X-Git-Tag: vmmhack1-ramdisk-boot-iso-puppy~32 X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=a91de70b95f386ce0cb8226cb12966a79adb6c42 Version that automatically checks RX packet size. Still receives multiple instances of packets. --- diff --git a/palacios/src/geekos/ne2k.c b/palacios/src/geekos/ne2k.c index 45fb49b..94aa91b 100644 --- a/palacios/src/geekos/ne2k.c +++ b/palacios/src/geekos/ne2k.c @@ -4,7 +4,7 @@ #include #include -#define DEBUG 0 +#define DEBUG 1 #define RX_START_BUFF 0x4c static uint_t received = 0; @@ -27,18 +27,19 @@ static void NE2K_Interrupt_Handler(struct Interrupt_State * state) Begin_IRQ(state); PrintBoth("NIC Interrupt Occured!\n"); uchar_t isr_content = In_Byte(NE2K_ISR); - Out_Byte(NE2K_ISR, 0xff); /* Clear all interrupts */ -/* if( !isr_content ) - return; -*/ + // Out_Byte(NE2K_ISR, 0xff); /* Clear all interrupts */ PrintBoth("Contents of ISR: %x\n", isr_content); if(isr_content & 0x01) - NE2K_Receive(); + { + NE2K_Receive(); + Out_Byte(NE2K_ISR, 0x01); +} End_IRQ(state); if(isr_content & 0x02) - send_done = 1; + send_done = 1; + } int Init_Ne2k() @@ -220,11 +221,13 @@ int NE2K_Receive() { PrintBoth("Packet Received\n"); - uint_t packet_size = 80; +// uint_t packet_size = 80; Out_Byte(NE2K_CR, 0x22); - Out_Byte(NE2K_RBCR0, packet_size); - Out_Byte(NE2K_RBCR1, 0x00); + + Out_Byte(NE2K_RBCR1, 0x00); +// Out_Byte(NE2K_RBCR0, 0x60); + // Out_Byte(NE2K_RSAR0, 0x42); Out_Byte(NE2K_RSAR1, next >> 8); Out_Byte(NE2K_RSAR0, next & 0xff); @@ -240,11 +243,19 @@ int NE2K_Receive() /* The first byte is the page number where the next packet in the ring buffer is stored */ next = data & 0xff00; + uint_t packet_size = In_Word(NE2K_CR + 0x10) - 4; + Out_Byte(NE2K_RBCR0, packet_size & 0xff); + Out_Byte(NE2K_RBCR1, (packet_size>>8) & 0xff); + +#if DEBUG + PrintBoth("packetsize = %x\n\t", packet_size); +#endif + for(i = 2; i < packet_size; i+=2) { data = In_Word(NE2K_CR + 0x10); PrintBoth("%x ", data); -#if DEBUG +#if 0 PrintBoth("BNRY = %x\n", In_Byte(NE2K_BNRY)); Out_Byte(NE2K_CR, 0x4a); PrintBoth("CURR = %x\n", In_Byte(NE2K_CURR));