Beispiel #1
0
//rx thread
DWORD WINAPI NetRxThread(LPVOID lpThreadParameter)
{	
	NetPacket tmp;
	while(RxRunning)
	{
		while(rx_fifo_can_rx() && nif->recv(&tmp))
		{
			rx_process(&tmp);
		}
		
		Sleep(10);
	}

	return 0;
}
Beispiel #2
0
void rx_process(NetPacket* pk)
{
	if (!rx_fifo_can_rx())
	{
		emu_printf("ERROR : !rx_fifo_can_rx at rx_process\n");
		return;
	}
	smap_bd_t *pbd= ((smap_bd_t *)&dev9.dev9R[SMAP_BD_RX_BASE & 0xffff])+dev9.rxbdi;

	int bytes=(pk->size+3)&(~3);

	if (!(pbd->ctrl_stat & SMAP_BD_RX_EMPTY)) 
	{
		emu_printf("ERROR : Discarding %d bytes (RX%d not ready)\n", bytes, dev9.rxbdi);
		return;
	}

	int pstart=(dev9.rxfifo_wr_ptr)&16383;
	int i=0;
	while(i<bytes)
	{
		dev9_rxfifo_write(pk->buffer[i++]);
		dev9.rxfifo_wr_ptr&=16383;
	}

	//increase RXBD
	dev9.rxbdi++;
	dev9.rxbdi&=(SMAP_BD_SIZE/8)-1;

	//Fill the BD with info !
	pbd->length = pk->size;
	pbd->pointer = 0x4000 + pstart;
	pbd->ctrl_stat&= ~SMAP_BD_RX_EMPTY;

	//increase frame count
	dev9Ru8(SMAP_R_RXFIFO_FRAME_CNT)++;
	//spams// emu_printf("Got packet, %d bytes (%d fifo)\n", pk->size,bytes);
	_DEV9irq(SMAP_INTR_RXEND,0);//now ? or when the fifo is full ? i guess now atm
								//note that this _is_ wrong since the IOP interrupt system is not thread safe.. but nothing i can do about that
}