Packets not arriving

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Is this better?

Code: Select all

	struct ne2000_t* ne = neDevs[0];
	uint8_t status;
	packet_t *p;
	
	// main loop
	while( 1 )
	{
		// check ISR bit
		unsigned char isr = inportb( ne->ioAddress + INTERRUPTSTATUS );
		
		// is it set for receive?
		if( status & 0x01 )
		{
			// clear the bit
			outportb( ne->ioAddress + INTERRUPTSTATUS, isr & 0xFE );
			
			// received
			p = readPacket( ne );
			handleEthernet( ne->eth, p );
		}
		else
		{
			// nope
			break;
		}
	}
Edit: the above doesn't work...
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

Like I said, you must read "CURRENT" pointer from page1, and deal with that. Otherwise you'll end up reading at most one packet per interrupt, and that won't work, because any interrupt might indicate any amount of packets.

You could look into the driver code I posted. :)
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

I see. Well, for now I'll keep my driver for testing (it works for now) but later I'll factor in your code.
Post Reply