2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Novell Eagle 2000 driver
5 * PURPOSE: DP8390 NIC specific routines
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * CSH 27/08-2000 Created
14 /* Null-terminated array of ports to probe. This is "semi-risky" (Don Becker). */
15 ULONG ProbeAddressList
[] = { 0x280, 0x300, 0x320, 0x340, 0x360, 0x380, 0 };
17 BOOLEAN
ProbeAddressForNIC(
20 * FUNCTION: Probes an address for a NIC
22 * address = Base address to probe
24 * TRUE if an NIC is found at the address
27 * If the adapter responds correctly to a
28 * stop command we assume it is present
33 NDIS_DbgPrint(MID_TRACE
, ("Probing address 0x%x\n", address
));
35 /* Disable interrupts */
36 NdisRawWritePortUchar(address
+ PG0_IMR
, 0);
39 NdisRawWritePortUchar(address
+ PG0_CR
, CR_STP
| CR_RD2
);
42 NdisStallExecution(1600);
44 /* Read NIC response */
45 NdisRawReadPortUchar(address
+ PG0_CR
, &Tmp
);
47 if ((Tmp
== (CR_RD2
| CR_STP
)) || (Tmp
== (CR_RD2
| CR_STP
| CR_STA
)))
57 * FUNCTION: Tests for a NIC
59 * Adapter = Pointer to adapter information
61 * TRUE if NIC is believed to be present, FALSE if not
66 NDIS_DbgPrint(MAX_TRACE
, ("Called\n"));
68 /* first try the supplied value */
69 if(ProbeAddressForNIC(Adapter
->IoBaseAddress
))
71 NDIS_DbgPrint(MIN_TRACE
, ("Found adapter at 0x%x\n", Adapter
->IoBaseAddress
));
75 /* ok, no dice, time to probe */
76 for(i
= 0; ProbeAddressList
[i
]; i
++)
78 if(ProbeAddressForNIC(ProbeAddressList
[i
]))
80 NDIS_DbgPrint(MIN_TRACE
, ("Found adapter at address 0x%x\n", ProbeAddressList
[i
]));
81 Adapter
->IoBaseAddress
= ProbeAddressList
[i
];
86 NDIS_DbgPrint(MIN_TRACE
,("Adapter NOT found!\n"));
91 BOOLEAN
NICTestAddress(
95 * FUNCTION: Tests if an address is writable
97 * Adapter = Pointer to adapter information
99 * TRUE if the address is writable, FALSE if not
106 NICReadDataAlign(Adapter
, &Data
, Address
, 0x02);
112 NICWriteDataAlign(Adapter
, Address
, &Data
, 0x02);
114 /* Check if it has changed on the NIC */
115 NICReadDataAlign(Adapter
, &Tmp
, Address
, 0x02);
117 return (Data
== Tmp
);
122 PNIC_ADAPTER Adapter
)
124 * FUNCTION: Finds out how much RAM a NIC has
126 * Adapter = Pointer to adapter information
128 * TRUE if the RAM size was found, FALSE if not
130 * Start at 1KB and test for every 1KB up to 64KB
135 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
137 /* Locate RAM base address */
138 for (Base
= 0x0400; Base
< 0x10000; Base
+= 0x0400) {
139 if (NICTestAddress(Adapter
, Base
))
143 if (Base
== 0x10000) {
144 /* No RAM on this board */
145 NDIS_DbgPrint(MIN_TRACE
, ("No RAM found on board.\n"));
149 Adapter
->RamBase
= (PUCHAR
)Base
;
152 for (; Base
< 0x10000; Base
+= 0x0400) {
153 if (!NICTestAddress(Adapter
, Base
))
157 Adapter
->RamSize
= (UINT
)(Base
- (ULONG_PTR
)Adapter
->RamBase
);
159 NDIS_DbgPrint(MID_TRACE
, ("RAM is at (0x%X). Size is (0x%X).\n",
160 Adapter
->RamBase
, Adapter
->RamSize
));
166 VOID
NICSetPhysicalAddress(
167 PNIC_ADAPTER Adapter
)
169 * FUNCTION: Initializes the physical address on the NIC
171 * Adapter = Pointer to adapter information
173 * The physical address is taken from Adapter.
174 * The NIC is stopped by this operation
180 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STP
| CR_RD2
| CR_PAGE1
);
182 /* Initialize PAR - Physical Address Registers */
183 for (i
= 0; i
< 0x06; i
++)
184 NdisRawWritePortUchar(Adapter
->IOBase
+ PG1_PAR
+ i
, Adapter
->StationAddress
[i
]);
186 /* Go back to page 0 */
187 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STP
| CR_RD2
| CR_PAGE0
);
191 VOID
NICSetMulticastAddressMask(
192 PNIC_ADAPTER Adapter
)
194 * FUNCTION: Initializes the multicast address mask on the NIC
196 * Adapter = Pointer to adapter information
198 * The multicast address mask is taken from Adapter.
199 * The NIC is stopped by this operation
205 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STP
| CR_RD2
| CR_PAGE1
);
207 /* Initialize MAR - Multicast Address Registers */
208 for (i
= 0; i
< 0x08; i
++)
209 NdisRawWritePortUchar(Adapter
->IOBase
+ PG1_MAR
+ i
, Adapter
->MulticastAddressMask
[i
]);
211 /* Go back to page 0 */
212 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STP
| CR_RD2
| CR_PAGE0
);
216 BOOLEAN
NICReadSAPROM(
217 PNIC_ADAPTER Adapter
)
219 * FUNCTION: Reads the Station Address PROM data from the NIC
221 * Adapter = Pointer to adapter information
223 * TRUE if a the NIC is an NE2000
225 * This routine also determines if the NIC can support word mode transfers
226 * and if it does initializes the NIC for word mode.
227 * The station address in the adapter structure is initialized with
228 * the address from the SAPROM
235 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
237 /* Read Station Address PROM (SAPROM) which is 16 bytes at remote DMA address 0.
238 Some cards double the data read which we must compensate for */
240 /* Initialize RBCR0 and RBCR1 - Remote Byte Count Registers */
241 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR0
, 0x20);
242 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR1
, 0x00);
244 /* Initialize RSAR0 and RSAR1 - Remote Start Address Registers */
245 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RSAR0
, 0x00);
246 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RSAR1
, 0x00);
248 /* Select page 0, read and start the NIC */
249 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD0
| CR_PAGE0
);
251 /* Read one byte at a time */
252 WordLength
= 2; /* Assume a word is two bytes */
253 for (i
= 0; i
< 32; i
+= 2) {
254 NdisRawReadPortUchar(Adapter
->IOBase
+ NIC_DATA
, &Buffer
[i
]);
255 NdisRawReadPortUchar(Adapter
->IOBase
+ NIC_DATA
, &Buffer
[i
+ 1]);
256 if (Buffer
[i
] != Buffer
[i
+ 1])
257 WordLength
= 1; /* A word is one byte long */
260 /* If WordLength is 2 the data read before was doubled. We must compensate for this */
261 if (WordLength
== 2) {
262 NDIS_DbgPrint(MAX_TRACE
,("NE2000 or compatible network adapter found.\n"));
264 Adapter
->WordMode
= TRUE
;
266 /* Move the SAPROM data to the adapter object */
267 for (i
= 0; i
< 16; i
++)
268 Adapter
->SAPROM
[i
] = Buffer
[i
* 2];
270 /* Copy the station address */
272 (PVOID
)&Adapter
->StationAddress
,
273 (PVOID
)&Adapter
->SAPROM
,
274 DRIVER_LENGTH_OF_ADDRESS
);
276 /* Initialize DCR - Data Configuration Register (word mode/4 words FIFO) */
277 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_DCR
, DCR_WTS
| DCR_LS
| DCR_FT10
);
281 NDIS_DbgPrint(MAX_TRACE
, ("NE1000 or compatible network adapter found.\n"));
283 Adapter
->WordMode
= FALSE
;
290 NDIS_STATUS
NICInitialize(
291 PNIC_ADAPTER Adapter
)
293 * FUNCTION: Initializes a NIC
295 * Adapter = Pointer to adapter information
297 * Status of NIC initialization
299 * The NIC is put into loopback mode
304 NDIS_DbgPrint(MID_TRACE
, ("Called.\n"));
307 NdisRawReadPortUchar(Adapter
->IOBase
+ NIC_RESET
, &Tmp
);
310 NdisStallExecution(1600);
312 /* Write the value back */
313 NdisRawWritePortUchar(Adapter
->IOBase
+ NIC_RESET
, Tmp
);
315 /* Select page 0 and stop NIC */
316 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STP
| CR_RD2
| CR_PAGE0
);
318 /* Initialize DCR - Data Configuration Register (byte mode/8 bytes FIFO) */
319 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_DCR
, DCR_LS
| DCR_FT10
);
321 /* Clear RBCR0 and RBCR1 - Remote Byte Count Registers */
322 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR0
, 0x00);
323 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR1
, 0x00);
325 /* Initialize RCR - Receive Configuration Register (monitor mode) */
326 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RCR
, RCR_MON
);
328 /* Enter loopback mode (internal NIC module loopback) */
329 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_TCR
, TCR_LOOP
);
331 /* Read the Station Address PROM */
332 if (!NICReadSAPROM(Adapter
))
333 return NDIS_STATUS_ADAPTER_NOT_FOUND
;
335 NDIS_DbgPrint(MID_TRACE
, ("Station address is (%02X %02X %02X %02X %02X %02X).\n",
336 Adapter
->StationAddress
[0], Adapter
->StationAddress
[1],
337 Adapter
->StationAddress
[2], Adapter
->StationAddress
[3],
338 Adapter
->StationAddress
[4], Adapter
->StationAddress
[5]));
340 /* Select page 0 and start NIC */
341 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD2
| CR_PAGE0
);
343 /* Clear ISR - Interrupt Status Register */
344 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_ISR
, 0xFF);
346 /* Find NIC RAM size */
349 return NDIS_STATUS_SUCCESS
;
353 NDIS_STATUS
NICSetup(
354 PNIC_ADAPTER Adapter
)
356 * FUNCTION: Sets up a NIC
358 * Adapter = Pointer to adapter information
360 * Status of operation
362 * The NIC is put into loopback mode
365 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
367 if (Adapter
->WordMode
) {
368 /* Initialize DCR - Data Configuration Register (word mode/4 words FIFO) */
369 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_DCR
, DCR_WTS
| DCR_LS
| DCR_FT10
);
371 /* Initialize DCR - Data Configuration Register (byte mode/8 bytes FIFO) */
372 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_DCR
, DCR_LS
| DCR_FT10
);
375 /* Clear RBCR0 and RBCR1 - Remote Byte Count Registers */
376 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR0
, 0x00);
377 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR1
, 0x00);
379 /* Initialize RCR - Receive Configuration Register (monitor mode) */
380 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RCR
, RCR_MON
);
382 /* Enter loopback mode (internal NIC module loopback) */
383 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_TCR
, TCR_LOOP
);
385 /* Set boundary page */
386 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_BNRY
, Adapter
->NextPacket
);
389 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_PSTART
, Adapter
->PageStart
);
392 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_PSTOP
, Adapter
->PageStop
);
394 /* Program our address on the NIC */
395 NICSetPhysicalAddress(Adapter
);
397 /* Program the multicast address mask on the NIC */
398 NICSetMulticastAddressMask(Adapter
);
400 /* Select page 1 and stop NIC */
401 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STP
| CR_RD2
| CR_PAGE1
);
403 /* Initialize current page register */
404 NdisRawWritePortUchar(Adapter
->IOBase
+ PG1_CURR
, Adapter
->PageStart
+ 1);
406 /* Select page 0 and stop NIC */
407 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STP
| CR_RD2
| CR_PAGE0
);
409 /* Clear ISR - Interrupt Status Register */
410 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_ISR
, 0xFF);
412 /* Initialize IMR - Interrupt Mask Register */
413 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_IMR
, Adapter
->InterruptMask
);
415 /* Select page 0 and start NIC */
416 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD2
| CR_PAGE0
);
418 Adapter
->CurrentPage
= Adapter
->PageStart
+ 1;
419 Adapter
->NextPacket
= Adapter
->PageStart
+ 1;
420 Adapter
->BufferOverflow
= FALSE
;
421 Adapter
->ReceiveError
= FALSE
;
422 Adapter
->TransmitError
= FALSE
;
424 NDIS_DbgPrint(MAX_TRACE
, ("Leaving.\n"));
426 return NDIS_STATUS_SUCCESS
;
430 NDIS_STATUS
NICStart(
431 PNIC_ADAPTER Adapter
)
433 * FUNCTION: Starts a NIC
435 * Adapter = Pointer to adapter information
437 * Status of operation
440 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
442 /* Take NIC out of loopback mode */
443 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_TCR
, 0x00);
445 /* Initialize RCR - Receive Configuration Register (accept all) */
446 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RCR
, RCR_AB
| RCR_AM
| RCR_PRO
);
448 return NDIS_STATUS_SUCCESS
;
453 PNIC_ADAPTER Adapter
)
455 * FUNCTION: Stops a NIC
457 * Adapter = Pointer to adapter information
459 * Status of operation
465 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
467 /* Select page 0 and stop NIC */
468 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STP
| CR_RD2
| CR_PAGE0
);
470 /* Clear Remote Byte Count Register so ISR_RST will be set */
471 NdisRawWritePortUchar( Adapter
->IOBase
+ PG0_RBCR0
, 0x00);
472 NdisRawWritePortUchar( Adapter
->IOBase
+ PG0_RBCR0
, 0x00);
474 /* Wait for ISR_RST to be set, but timeout after 2ms */
475 for (i
= 0; i
< 4; i
++) {
476 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_ISR
, &Tmp
);
480 NdisStallExecution(500);
485 NDIS_DbgPrint(MIN_TRACE
, ("NIC was not reset after 2ms.\n"));
488 /* Initialize RCR - Receive Configuration Register (monitor mode) */
489 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RCR
, RCR_MON
);
491 /* Initialize TCR - Transmit Configuration Register (loopback mode) */
492 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_TCR
, TCR_LOOP
);
495 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD2
);
497 return NDIS_STATUS_SUCCESS
;
501 NDIS_STATUS
NICReset(
502 PNIC_ADAPTER Adapter
)
504 * FUNCTION: Resets a NIC
506 * Adapter = Pointer to adapter information
508 * Status of operation
513 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
519 NdisRawReadPortUchar(Adapter
->IOBase
+ NIC_RESET
, &Tmp
);
522 NdisStallExecution(1600);
524 /* Write the value back */
525 NdisRawWritePortUchar(Adapter
->IOBase
+ NIC_RESET
, Tmp
);
527 /* Restart the NIC */
530 return NDIS_STATUS_SUCCESS
;
534 VOID
NICStartTransmit(
535 PNIC_ADAPTER Adapter
)
537 * FUNCTION: Starts transmitting a packet
539 * Adapter = Pointer to adapter information
546 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
548 //FrameStart = Adapter->TXStart + Adapter->TXCurrent * DRIVER_BLOCK_SIZE;
549 //FrameStart = Adapter->TXStart;
550 FrameStart
= (UCHAR
)(Adapter
->TXStart
+ (UCHAR
)(Adapter
->TXCurrent
* BUFFERS_PER_TX_BUF
));
552 /* Set start of frame */
553 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_TPSR
, &Tmp
);
554 // NdisRawWritePortUchar(Adapter->IOBase + PG0_TPSR,
555 // Adapter->TXStart + Adapter->TXCurrent * DRIVER_BLOCK_SIZE);
557 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_TPSR
, FrameStart
);
558 //NDIS_DbgPrint(MID_TRACE, ("Setting start of frame to (%d).\n", FrameStart));
560 /* Set length of frame */
561 Length
= Adapter
->TXSize
[Adapter
->TXCurrent
];
562 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_TBCR0
, Length
& 0xFF);
563 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_TBCR1
, Length
>> 8);
565 /* Start transmitting */
566 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_TXP
| CR_RD2
);
568 NDIS_DbgPrint(MID_TRACE
, ("Transmitting. FrameStart (%d) TXCurrent (%d) TXStart (%d) Length (%d).\n\n",
577 VOID
NICSetBoundaryPage(
578 PNIC_ADAPTER Adapter
)
580 * FUNCTION: Sets the boundary page on the adapter to be one less than NextPacket
582 * Adapter = Pointer to adapter information
585 if (Adapter
->NextPacket
== Adapter
->PageStart
) {
586 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_BNRY
,
587 (UCHAR
)(Adapter
->PageStop
- 1));
589 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_BNRY
,
590 (UCHAR
)(Adapter
->NextPacket
- 1));
595 VOID
NICGetCurrentPage(
596 PNIC_ADAPTER Adapter
)
598 * FUNCTION: Retrieves the current page from the adapter
600 * Adapter = Pointer to adapter information
606 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD2
| CR_PAGE1
);
608 /* Read current page */
609 NdisRawReadPortUchar(Adapter
->IOBase
+ PG1_CURR
, &Current
);
612 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD2
| CR_PAGE0
);
614 Adapter
->CurrentPage
= Current
;
618 VOID
NICUpdateCounters(
619 PNIC_ADAPTER Adapter
)
621 * FUNCTION: Updates counters
623 * Adapter = Pointer to adapter information
628 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
630 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_CNTR0
, &Tmp
);
631 Adapter
->FrameAlignmentErrors
+= Tmp
;
633 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_CNTR1
, &Tmp
);
634 Adapter
->CrcErrors
+= Tmp
;
636 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_CNTR2
, &Tmp
);
637 Adapter
->MissedPackets
+= Tmp
;
641 VOID
NICReadDataAlign(
642 PNIC_ADAPTER Adapter
,
647 * FUNCTION: Copies data from a NIC's RAM into a buffer
649 * Adapter = Pointer to adapter information
650 * Target = Pointer to buffer to copy data into (in host memory)
651 * Source = Offset into NIC's RAM (must be an even number)
652 * Length = Number of bytes to copy from NIC's RAM (must be an even number)
660 /* Select page 0 and start the NIC */
661 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD2
| CR_PAGE0
);
663 /* Initialize RSAR0 and RSAR1 - Remote Start Address Registers */
664 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RSAR0
, (UCHAR
)(Source
& 0xFF));
665 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RSAR1
, (UCHAR
)(Source
>> 8));
667 /* Initialize RBCR0 and RBCR1 - Remote Byte Count Registers */
668 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR0
, (UCHAR
)(Count
& 0xFF));
669 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR1
, (UCHAR
)(Count
>> 8));
671 /* Select page 0, read and start the NIC */
672 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD0
| CR_PAGE0
);
674 if (Adapter
->WordMode
)
675 NdisRawReadPortBufferUshort(Adapter
->IOBase
+ NIC_DATA
, Target
, Count
>> 1);
677 NdisRawReadPortBufferUchar(Adapter
->IOBase
+ NIC_DATA
, Target
, Count
);
679 /* Wait for remote DMA to complete, but timeout after some time */
680 for (Count
= 0; Count
< 0xFFFF; Count
++) {
681 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_ISR
, &Tmp
);
685 NdisStallExecution(4);
690 NDIS_DbgPrint(MIN_TRACE
, ("Remote DMA did not complete.\n"));
693 /* Clear remote DMA bit in ISR - Interrupt Status Register */
694 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_ISR
, ISR_RDC
);
698 VOID
NICWriteDataAlign(
699 PNIC_ADAPTER Adapter
,
704 * FUNCTION: Copies data from a buffer into the NIC's RAM
706 * Adapter = Pointer to adapter information
707 * Target = Offset into NIC's RAM (must be an even number)
708 * Source = Pointer to buffer to copy data from (in host memory)
709 * Length = Number of bytes to copy from the buffer (must be an even number)
715 /* Select page 0 and start the NIC */
716 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD2
| CR_PAGE0
);
718 /* Handle read-before-write bug */
720 /* Initialize RSAR0 and RSAR1 - Remote Start Address Registers */
721 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RSAR0
, (UCHAR
)(Target
& 0xFF));
722 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RSAR1
, (UCHAR
)(Target
>> 8));
724 /* Initialize RBCR0 and RBCR1 - Remote Byte Count Registers */
725 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR0
, 0x02);
726 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR1
, 0x00);
728 /* Read and start the NIC */
729 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD0
| CR_PAGE0
);
732 NdisRawReadPortUshort(Adapter
->IOBase
+ NIC_DATA
, &Count
);
734 /* Wait for remote DMA to complete, but timeout after some time */
735 for (Count
= 0; Count
< 0xFFFF; Count
++) {
736 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_ISR
, &Tmp
);
740 NdisStallExecution(4);
745 NDIS_DbgPrint(MIN_TRACE
, ("Remote DMA did not complete.\n"));
748 /* Clear remote DMA bit in ISR - Interrupt Status Register */
749 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_ISR
, ISR_RDC
);
752 /* Now output some data */
755 /* Initialize RSAR0 and RSAR1 - Remote Start Address Registers */
756 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RSAR0
, (UCHAR
)(Target
& 0xFF));
757 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RSAR1
, (UCHAR
)(Target
>> 8));
759 /* Initialize RBCR0 and RBCR1 - Remote Byte Count Registers */
760 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR0
, (UCHAR
)(Count
& 0xFF));
761 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR1
, (UCHAR
)(Count
>> 8));
763 /* Write and start the NIC */
764 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD1
| CR_PAGE0
);
766 if (Adapter
->WordMode
)
767 NdisRawWritePortBufferUshort(Adapter
->IOBase
+ NIC_DATA
, Source
, Count
>> 1);
769 NdisRawWritePortBufferUchar(Adapter
->IOBase
+ NIC_DATA
, Source
, Count
);
771 /* Wait for remote DMA to complete, but timeout after some time */
772 for (Count
= 0; Count
< 0xFFFF; Count
++) {
773 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_ISR
, &Tmp
);
777 NdisStallExecution(4);
782 NDIS_DbgPrint(MIN_TRACE
, ("Remote DMA did not complete.\n"));
785 /* Clear remote DMA bit in ISR - Interrupt Status Register */
786 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_ISR
, ISR_RDC
);
791 PNIC_ADAPTER Adapter
,
796 * FUNCTION: Copies data from a NIC's RAM into a buffer
798 * Adapter = Pointer to adapter information
799 * Target = Pointer to buffer to copy data into (in host memory)
800 * Source = Offset into NIC's RAM
801 * Length = Number of bytes to copy from NIC's RAM
806 /* Avoid transfers to odd addresses */
808 /* Transfer one word and use the MSB */
809 NICReadDataAlign(Adapter
, &Tmp
, Source
- 1, 0x02);
810 *Target
= (UCHAR
)(Tmp
>> 8);
817 /* Transfer as many words as we can without exceeding the buffer length */
818 Tmp
= Length
& 0xFFFE;
819 NICReadDataAlign(Adapter
, (PUSHORT
)Target
, Source
, Tmp
);
821 Target
= (PUCHAR
)((ULONG_PTR
) Target
+ Tmp
);
823 /* Read one word and keep the LSB */
824 NICReadDataAlign(Adapter
, &Tmp
, Source
, 0x02);
825 *Target
= (UCHAR
)(Tmp
& 0x00FF);
827 /* Transfer the rest of the data */
828 NICReadDataAlign(Adapter
, (PUSHORT
)Target
, Source
, Length
);
833 PNIC_ADAPTER Adapter
,
838 * FUNCTION: Copies data from a buffer into NIC's RAM
840 * Adapter = Pointer to adapter information
841 * Target = Offset into NIC's RAM to store data
842 * Source = Pointer to buffer to copy data from (in host memory)
843 * Length = Number of bytes to copy from buffer
848 /* Avoid transfers to odd addresses */
851 NICReadDataAlign(Adapter
, &Tmp
, Target
- 1, 0x02);
853 /* Merge LSB with the new byte which become the new MSB */
854 Tmp
= (Tmp
& 0x00FF) | (*Source
<< 8);
856 /* Finally write the value back */
857 NICWriteDataAlign(Adapter
, Target
- 1, &Tmp
, 0x02);
859 /* Update pointers */
860 Source
= (PUCHAR
) ((ULONG_PTR
) Source
+ 1);
866 /* Transfer as many words as we can without exceeding the transfer length */
867 Tmp
= Length
& 0xFFFE;
868 NICWriteDataAlign(Adapter
, Target
, (PUSHORT
)Source
, Tmp
);
873 NICReadDataAlign(Adapter
, &Tmp
, Target
, 0x02);
875 /* Merge MSB with the new byte which become the new LSB */
876 Tmp
= (Tmp
& 0xFF00) | (*Source
);
878 /* Finally write the value back */
879 NICWriteDataAlign(Adapter
, Target
, &Tmp
, 0x02);
881 /* Transfer the rest of the data */
882 NICWriteDataAlign(Adapter
, Target
, (PUSHORT
)Source
, Length
);
886 VOID
NICIndicatePacket(
887 PNIC_ADAPTER Adapter
)
889 * FUNCTION: Indicates a packet to the wrapper
891 * Adapter = Pointer to adapter information
896 IndicateLength
= (Adapter
->PacketHeader
.PacketLength
<
897 (Adapter
->LookaheadSize
+ DRIVER_HEADER_SIZE
))?
898 (Adapter
->PacketHeader
.PacketLength
) :
899 (Adapter
->LookaheadSize
+ DRIVER_HEADER_SIZE
);
901 /* Fill the lookahead buffer */
903 (PUCHAR
)&Adapter
->Lookahead
,
904 Adapter
->PacketOffset
+ sizeof(PACKET_HEADER
),
905 IndicateLength
+ DRIVER_HEADER_SIZE
);
907 NDIS_DbgPrint(MID_TRACE
, ("Indicating (%d) bytes.\n", IndicateLength
));
908 DbgPrint("ne2000!NICIndicatePacket: Indicating (%d) bytes.\n", IndicateLength
);
911 NDIS_DbgPrint(MAX_TRACE
, ("FRAME:\n"));
912 for (i
= 0; i
< (IndicateLength
+ 7) / 8; i
++) {
913 NDIS_DbgPrint(MAX_TRACE
, ("%02X %02X %02X %02X %02X %02X %02X %02X\n",
914 Adapter
->Lookahead
[i
*8+0],
915 Adapter
->Lookahead
[i
*8+1],
916 Adapter
->Lookahead
[i
*8+2],
917 Adapter
->Lookahead
[i
*8+3],
918 Adapter
->Lookahead
[i
*8+4],
919 Adapter
->Lookahead
[i
*8+5],
920 Adapter
->Lookahead
[i
*8+6],
921 Adapter
->Lookahead
[i
*8+7]));
925 if (IndicateLength
>= DRIVER_HEADER_SIZE
) {
926 NDIS_DbgPrint(MAX_TRACE
,("Adapter->MiniportAdapterHandle: %x\n",
927 Adapter
->MiniportAdapterHandle
));
928 NdisMEthIndicateReceive(Adapter
->MiniportAdapterHandle
,
930 (PVOID
)&Adapter
->Lookahead
,
932 (PVOID
)&Adapter
->Lookahead
[DRIVER_HEADER_SIZE
],
933 IndicateLength
- DRIVER_HEADER_SIZE
,
934 Adapter
->PacketHeader
.PacketLength
- DRIVER_HEADER_SIZE
);
936 NdisMEthIndicateReceive(Adapter
->MiniportAdapterHandle
,
938 (PVOID
)&Adapter
->Lookahead
,
948 PNIC_ADAPTER Adapter
)
950 * FUNCTION: Reads a full packet from the receive buffer ring
952 * Adapter = Pointer to adapter information
955 BOOLEAN SkipPacket
= FALSE
;
957 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
959 /* Get the header of the next packet in the receive ring */
960 Adapter
->PacketOffset
= Adapter
->NextPacket
<< 8;
962 (PUCHAR
)&Adapter
->PacketHeader
,
963 Adapter
->PacketOffset
,
964 sizeof(PACKET_HEADER
));
966 NDIS_DbgPrint(MAX_TRACE
, ("HEADER: (Status) (0x%X)\n", Adapter
->PacketHeader
.Status
));
967 NDIS_DbgPrint(MAX_TRACE
, ("HEADER: (NextPacket) (0x%X)\n", Adapter
->PacketHeader
.NextPacket
));
968 NDIS_DbgPrint(MAX_TRACE
, ("HEADER: (PacketLength) (0x%X)\n", Adapter
->PacketHeader
.PacketLength
));
970 if (Adapter
->PacketHeader
.PacketLength
< 64 ||
971 Adapter
->PacketHeader
.PacketLength
> 1518) { /* XXX I don't think the CRC will show up... should be 1514 */
972 NDIS_DbgPrint(MAX_TRACE
, ("Bogus packet size (%d).\n",
973 Adapter
->PacketHeader
.PacketLength
));
979 Adapter
->NextPacket
= Adapter
->CurrentPage
;
981 NDIS_DbgPrint(MAX_TRACE
,("Adapter->MiniportAdapterHandle: %x\n",
982 Adapter
->MiniportAdapterHandle
));
983 NICIndicatePacket(Adapter
);
985 /* Go to the next free buffer in receive ring */
986 Adapter
->NextPacket
= Adapter
->PacketHeader
.NextPacket
;
989 /* Update boundary page */
990 NICSetBoundaryPage(Adapter
);
995 PNIC_ADAPTER Adapter
)
997 * FUNCTION: Writes a full packet to the transmit buffer ring
999 * Adapter = Pointer to adapter information
1001 * There must be enough free buffers available in the transmit buffer ring.
1002 * The packet is taken from the head of the transmit queue and the position
1003 * into the transmit buffer ring is taken from TXNext
1006 PNDIS_BUFFER SrcBuffer
;
1007 UINT BytesToCopy
, SrcSize
, DstSize
;
1013 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
1015 TXStart
= Adapter
->TXStart
* DRIVER_BLOCK_SIZE
;
1016 TXStop
= (Adapter
->TXStart
+ Adapter
->TXCount
) * DRIVER_BLOCK_SIZE
;
1018 NdisQueryPacket(Adapter
->TXQueueHead
,
1022 &Adapter
->TXSize
[Adapter
->TXNext
]);
1024 NDIS_DbgPrint(MID_TRACE
, ("Packet (%d) is now size (%d).\n",
1026 Adapter
->TXSize
[Adapter
->TXNext
]));
1028 NdisQueryBuffer(SrcBuffer
, (PVOID
)&SrcData
, &SrcSize
);
1030 DstData
= TXStart
+ Adapter
->TXNext
* DRIVER_BLOCK_SIZE
;
1031 DstSize
= TXStop
- DstData
;
1033 /* Start copying the data */
1035 BytesToCopy
= (SrcSize
< DstSize
)? SrcSize
: DstSize
;
1037 NICWriteData(Adapter
, DstData
, SrcData
, BytesToCopy
);
1039 SrcData
= (PUCHAR
)((ULONG_PTR
) SrcData
+ BytesToCopy
);
1040 SrcSize
-= BytesToCopy
;
1041 DstData
+= BytesToCopy
;
1042 DstSize
-= BytesToCopy
;
1045 /* No more bytes in source buffer. Proceed to
1046 the next buffer in the source buffer chain */
1047 NdisGetNextBuffer(SrcBuffer
, &SrcBuffer
);
1051 NdisQueryBuffer(SrcBuffer
, (PVOID
)&SrcData
, &SrcSize
);
1055 /* Wrap around the end of the transmit buffer ring */
1057 DstSize
= Adapter
->TXCount
* DRIVER_BLOCK_SIZE
;
1063 BOOLEAN
NICPrepareForTransmit(
1064 PNIC_ADAPTER Adapter
)
1066 * FUNCTION: Prepares a packet for transmission
1068 * Adapter = Pointer to adapter information
1070 * There must be at least one packet in the transmit queue
1072 * TRUE if a packet was prepared, FALSE if not
1077 PNDIS_PACKET Packet
;
1079 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
1081 /* Calculate number of buffers needed to transmit packet */
1082 NdisQueryPacket(Adapter
->TXQueueHead
,
1088 BufferCount
= (Length
+ DRIVER_BLOCK_SIZE
- 1) / DRIVER_BLOCK_SIZE
;
1090 if (BufferCount
> Adapter
->TXFree
) {
1091 NDIS_DbgPrint(MID_TRACE
, ("No transmit resources. Have (%d) buffers, need (%d).\n",
1092 Adapter
->TXFree
, BufferCount
));
1093 /* We don't have the resources to transmit this packet right now */
1097 /* Write the packet to the card */
1098 NICWritePacket(Adapter
);
1100 /* If the NIC is not transmitting, reset the current transmit pointer */
1101 if (Adapter
->TXCurrent
== -1)
1102 Adapter
->TXCurrent
= Adapter
->TXNext
;
1104 Adapter
->TXNext
= (Adapter
->TXNext
+ BufferCount
) % Adapter
->TXCount
;
1105 Adapter
->TXFree
-= BufferCount
;
1107 /* Remove the packet from the queue */
1108 Packet
= Adapter
->TXQueueHead
;
1109 Adapter
->TXQueueHead
= RESERVED(Packet
)->Next
;
1111 if (Packet
== Adapter
->TXQueueTail
)
1112 Adapter
->TXQueueTail
= NULL
;
1114 /* Assume the transmit went well */
1115 NdisMSendComplete(Adapter
->MiniportAdapterHandle
,
1117 NDIS_STATUS_SUCCESS
);
1124 PNIC_ADAPTER Adapter
)
1126 * FUNCTION: Starts transmitting packets in the transmit queue
1128 * Adapter = Pointer to adapter information
1130 * There must be at least one packet in the transmit queue
1133 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
1135 if (Adapter
->TXCurrent
== -1) {
1136 /* NIC is not transmitting, so start transmitting now */
1138 /* Load next packet onto the card, and start transmitting */
1139 if (NICPrepareForTransmit(Adapter
))
1140 NICStartTransmit(Adapter
);
1146 PNIC_ADAPTER Adapter
)
1148 * FUNCTION: Handles reception of a packet
1150 * Adapter = Pointer to adapter information
1152 * Buffer overflows are also handled here
1159 NDIS_DbgPrint(MAX_TRACE
, ("Called.\n"));
1161 Adapter
->DoneIndicating
= FALSE
;
1164 NICGetCurrentPage(Adapter
);
1166 if (Adapter
->BufferOverflow
) {
1168 NDIS_DbgPrint(MID_TRACE
, ("Receive ring overflow.\n"));
1170 /* Select page 0 and stop the NIC */
1171 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STP
| CR_RD2
| CR_PAGE0
);
1173 /* Clear RBCR0,RBCR1 - Remote Byte Count Registers */
1174 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR0
, 0x00);
1175 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_RBCR1
, 0x00);
1177 /* Wait for ISR_RST to be set, but timeout after 2ms */
1178 for (i
= 0; i
< 4; i
++) {
1179 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_ISR
, &Tmp
);
1183 NdisStallExecution(500);
1188 NDIS_DbgPrint(MIN_TRACE
, ("NIC was not reset after 2ms.\n"));
1191 if ((Adapter
->InterruptStatus
& (ISR_PTX
| ISR_TXE
)) == 0) {
1192 /* We may need to restart the transmitter */
1193 Adapter
->TransmitPending
= TRUE
;
1196 /* Initialize TCR - Transmit Configuration Register to loopback mode 1 */
1197 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_TCR
, TCR_LOOP
);
1200 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_CR
, CR_STA
| CR_RD2
);
1204 Adapter
->BufferOverflow
= FALSE
;
1207 if (Adapter
->ReceiveError
) {
1208 NDIS_DbgPrint(MID_TRACE
, ("Receive error.\n"));
1210 /* Skip this packet */
1211 Adapter
->NextPacket
= Adapter
->CurrentPage
;
1212 NICSetBoundaryPage(Adapter
);
1214 Adapter
->ReceiveError
= FALSE
;
1218 NICGetCurrentPage(Adapter
);
1220 NDIS_DbgPrint(MID_TRACE
, ("Current page (0x%X) NextPacket (0x%X).\n",
1221 Adapter
->CurrentPage
,
1222 Adapter
->NextPacket
));
1224 if (Adapter
->CurrentPage
== Adapter
->NextPacket
) {
1225 NDIS_DbgPrint(MID_TRACE
, ("No more packets.\n"));
1228 NDIS_DbgPrint(MID_TRACE
, ("Got a packet in the receive ring.\n"));
1230 NDIS_DbgPrint(MAX_TRACE
,("Adapter->MiniportAdapterHandle: %x\n",
1231 Adapter
->MiniportAdapterHandle
));
1232 /* Read packet from receive buffer ring */
1233 NICReadPacket(Adapter
);
1235 Adapter
->DoneIndicating
= TRUE
;
1238 if (PacketCount
== 10) {
1239 /* Don't starve transmit interrupts */
1245 if ((Adapter
->TransmitPending
) && (Adapter
->TXCurrent
!= -1)) {
1246 NDIS_DbgPrint(MID_TRACE
, ("Retransmitting current packet at (%d).\n", Adapter
->TXCurrent
));
1247 /* Retransmit packet */
1248 NICStartTransmit(Adapter
);
1249 Adapter
->TransmitPending
= FALSE
;
1252 if (Adapter
->DoneIndicating
)
1253 NdisMEthIndicateReceiveComplete(Adapter
->MiniportAdapterHandle
);
1257 VOID
HandleTransmit(
1258 PNIC_ADAPTER Adapter
)
1260 * FUNCTION: Handles transmission of a packet
1262 * Adapter = Pointer to adapter information
1268 // PIP_PACKET pIPPacket;
1269 // pIPPacket = (PIP_PACKET)
1270 // DisplayIPPacket(pIPPacket);
1272 if (Adapter
->TransmitError
) {
1273 /* FIXME: Retransmit now or let upper layer protocols handle retransmit? */
1274 Adapter
->TransmitError
= FALSE
;
1277 /* Free transmit buffers */
1278 Length
= Adapter
->TXSize
[Adapter
->TXCurrent
];
1279 BufferCount
= (Length
+ DRIVER_BLOCK_SIZE
- 1) / DRIVER_BLOCK_SIZE
;
1281 NDIS_DbgPrint(MID_TRACE
, ("Freeing (%d) buffers at (%d).\n",
1283 Adapter
->TXCurrent
));
1285 Adapter
->TXFree
+= BufferCount
;
1286 Adapter
->TXSize
[Adapter
->TXCurrent
] = 0;
1287 Adapter
->TXCurrent
= (Adapter
->TXCurrent
+ BufferCount
) % Adapter
->TXCount
;
1289 if (Adapter
->TXSize
[Adapter
->TXCurrent
] == 0) {
1290 NDIS_DbgPrint(MID_TRACE
, ("No more packets in transmit buffer.\n"));
1292 Adapter
->TXCurrent
= -1;
1295 if (Adapter
->TXQueueTail
) {
1296 if (NICPrepareForTransmit(Adapter
))
1297 NICStartTransmit(Adapter
);
1302 VOID STDCALL
MiniportHandleInterrupt(
1303 IN NDIS_HANDLE MiniportAdapterContext
)
1305 * FUNCTION: Handler for deferred processing of interrupts
1307 * MiniportAdapterContext = Pointer to adapter context area
1309 * Interrupt Service Register is read to determine which interrupts
1310 * are pending. All pending interrupts are handled
1316 PNIC_ADAPTER Adapter
= (PNIC_ADAPTER
)MiniportAdapterContext
;
1318 ISRMask
= Adapter
->InterruptMask
;
1319 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_ISR
, &ISRValue
);
1321 NDIS_DbgPrint(MID_TRACE
, ("ISRValue (0x%X).\n", ISRValue
));
1323 Adapter
->InterruptStatus
|= (ISRValue
& ISRMask
);
1325 if (ISRValue
!= 0x00)
1326 /* Acknowledge interrupts */
1327 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_ISR
, ISRValue
);
1330 while (Adapter
->InterruptStatus
!= 0x00) {
1332 NDIS_DbgPrint(MID_TRACE
, ("Adapter->InterruptStatus (0x%X) Mask (0x%X).\n",
1333 Adapter
->InterruptStatus
, Mask
));
1335 /* Find next interrupt type */
1336 while (((Adapter
->InterruptStatus
& Mask
) == 0) && (Mask
< ISRMask
))
1339 switch (Adapter
->InterruptStatus
& Mask
) {
1341 NDIS_DbgPrint(MID_TRACE
, ("Overflow interrupt.\n"));
1342 /* Overflow. Handled almost the same way as a receive interrupt */
1343 Adapter
->BufferOverflow
= TRUE
;
1345 NDIS_DbgPrint(MAX_TRACE
,("Adapter->MiniportAdapterHandle: %x\n",
1346 Adapter
->MiniportAdapterHandle
));
1347 if(Adapter
->MiniportAdapterHandle
)
1348 HandleReceive(Adapter
);
1350 NDIS_DbgPrint(MAX_TRACE
,("No miniport adapter yet\n"));
1352 Adapter
->InterruptStatus
&= ~ISR_OVW
;
1356 NDIS_DbgPrint(MID_TRACE
, ("Receive error interrupt.\n"));
1357 NICUpdateCounters(Adapter
);
1359 Adapter
->ReceiveError
= TRUE
;
1362 NDIS_DbgPrint(MID_TRACE
, ("Receive interrupt.\n"));
1364 NDIS_DbgPrint(MAX_TRACE
,("Adapter->MiniportAdapterHandle: %x\n",
1365 Adapter
->MiniportAdapterHandle
));
1366 if(Adapter
->MiniportAdapterHandle
)
1367 HandleReceive(Adapter
);
1369 NDIS_DbgPrint(MAX_TRACE
,("No miniport adapter yet\n"));
1371 Adapter
->InterruptStatus
&= ~(ISR_PRX
| ISR_RXE
);
1375 NDIS_DbgPrint(MID_TRACE
, ("Transmit error interrupt.\n"));
1376 NICUpdateCounters(Adapter
);
1378 Adapter
->TransmitError
= TRUE
;
1381 NDIS_DbgPrint(MID_TRACE
, ("Transmit interrupt.\n"));
1383 HandleTransmit(Adapter
);
1385 Adapter
->InterruptStatus
&= ~(ISR_PTX
| ISR_TXE
);
1389 NDIS_DbgPrint(MID_TRACE
, ("Counter interrupt.\n"));
1390 /* Counter overflow. Read counters from the NIC */
1391 NICUpdateCounters(Adapter
);
1393 Adapter
->InterruptStatus
&= ~ISR_CNT
;
1397 NDIS_DbgPrint(MID_TRACE
, ("Unknown interrupt. Adapter->InterruptStatus (0x%X).\n", Adapter
->InterruptStatus
));
1398 Adapter
->InterruptStatus
&= ~Mask
;
1404 /* Check if new interrupts are generated */
1406 NdisRawReadPortUchar(Adapter
->IOBase
+ PG0_ISR
, &ISRValue
);
1408 NDIS_DbgPrint(MID_TRACE
, ("ISRValue (0x%X).\n", ISRValue
));
1410 Adapter
->InterruptStatus
|= (ISRValue
& ISRMask
);
1412 if (ISRValue
!= 0x00) {
1413 /* Acknowledge interrupts */
1414 NdisRawWritePortUchar(Adapter
->IOBase
+ PG0_ISR
, ISRValue
);
1419 NICEnableInterrupts((PNIC_ADAPTER
)MiniportAdapterContext
);