MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / tx_process

Function tx_process

pcsx2/DEV9/smap.cpp:120–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void tx_process()
121{
122 NetPacket pk;
123 // We will loop though TX_BD, sending any that are ready
124 // stopping once we reach one that isn't ready
125 // SMAP_R_TXFIFO_FRAME_CNT is decremented, but otherwise isn't used
126 // This seems to match HW behaviour
127 u32 cnt = 0;
128 while (true)
129 {
130 smap_bd_t* pbd = ((smap_bd_t*)&dev9.dev9R[SMAP_BD_TX_BASE & 0xffff]) + dev9.txbdi;
131
132 if (!(pbd->ctrl_stat & SMAP_BD_TX_READY))
133 {
134 break;
135 }
136 if (pbd->length & 3)
137 {
138 //spams// emu_printf("WARN : pbd->length not aligned %u\n",pbd->length);
139 }
140
141 if (pbd->length > 1514)
142 {
143 Console.Error("DEV9: SMAP: ERROR : Trying to send packet too big.");
144 }
145 else
146 {
147 const u32 base = (pbd->pointer - 0x1000) & 16383;
148 DevCon.WriteLn("DEV9: Sending Packet from base %x, size %d", base, pbd->length);
149
150 pk.size = pbd->length;
151
152 if (!(pbd->pointer >= 0x1000))
153 {
154 Console.Error("DEV9: SMAP: ERROR: odd , !pbd->pointer>0x1000 | 0x%X %u", pbd->pointer, pbd->length);
155 }
156
157 // SMAP drivers send a very specfic frame during init, then check SPD_R_INTR_STAT for SMAP_INTR_RXEND | SMAP_INTR_TXEND | SMAP_INTR_TXDNV.
158 // SMAP_INTR_TXEND is set normally, SMAP_INTR_RXEND is supposed to be set here, but we currently don't emulate that.
159 // SMAP_INTR_TXDNV is set somewhere, unsure where, we only set it in failure (instead of SMAP_INTR_TXEND), but is included in the hack here.
160 if (pbd->length == 0x5EA && pbd->pointer == 0x1000)
161 {
162 u32* ptr = (u32*)&dev9.txfifo[base];
163
164 bool test = true;
165 for (u32 i = 0; i < 0x5EA; i += 4)
166 {
167 if (*ptr++ != i)
168 {
169 test = false;
170 break;
171 }
172 }
173 if (test)
174 {
175 Console.WriteLn("DEV9: Adapter Detection Hack - Resetting RX/TX");
176 _DEV9irq(SMAP_INTR_RXEND | SMAP_INTR_TXDNV, 100);
177 }

Callers 1

emac3_writeFunction · 0.85

Calls 4

_DEV9irqFunction · 0.85
tx_putFunction · 0.85
ErrorMethod · 0.45
WriteLnMethod · 0.45

Tested by

no test coverage detected