summaryrefslogtreecommitdiffstats
path: root/private/ntos/ndis/ubnei
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--private/ntos/ndis/ubnei/card.c1910
-rw-r--r--private/ntos/ndis/ubnei/config.c532
-rw-r--r--private/ntos/ndis/ubnei/debug.h90
-rw-r--r--private/ntos/ndis/ubnei/init.c770
-rw-r--r--private/ntos/ndis/ubnei/initdata.c223
-rw-r--r--private/ntos/ndis/ubnei/interrup.c337
-rw-r--r--private/ntos/ndis/ubnei/keywords.h57
-rw-r--r--private/ntos/ndis/ubnei/makefile6
-rw-r--r--private/ntos/ndis/ubnei/makefile.inc5
-rw-r--r--private/ntos/ndis/ubnei/map.c256
-rw-r--r--private/ntos/ndis/ubnei/map.h164
-rw-r--r--private/ntos/ndis/ubnei/niudata.h562
-rw-r--r--private/ntos/ndis/ubnei/receive.c482
-rw-r--r--private/ntos/ndis/ubnei/request.c713
-rw-r--r--private/ntos/ndis/ubnei/send.c369
-rw-r--r--private/ntos/ndis/ubnei/sources55
-rw-r--r--private/ntos/ndis/ubnei/ubhard.h303
-rw-r--r--private/ntos/ndis/ubnei/ubnei.binbin0 -> 5420 bytes
-rw-r--r--private/ntos/ndis/ubnei/ubnei.c567
-rw-r--r--private/ntos/ndis/ubnei/ubnei.h332
-rw-r--r--private/ntos/ndis/ubnei/ubnei.rc12
-rw-r--r--private/ntos/ndis/ubnei/ubsoft.h381
22 files changed, 8126 insertions, 0 deletions
diff --git a/private/ntos/ndis/ubnei/card.c b/private/ntos/ndis/ubnei/card.c
new file mode 100644
index 000000000..59e41e335
--- /dev/null
+++ b/private/ntos/ndis/ubnei/card.c
@@ -0,0 +1,1910 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ card.c
+
+Abstract:
+
+ This is the mac ndis file for the Ungermann Bass Ethernet Controller.
+ This driver conforms to the NDIS 3.0 interface.
+
+ It is here that the NDIS3.0 functions defined in the MAC characteristic
+ table have been deinfed.
+
+Author:
+
+ Sanjeev Katariya (sanjeevk) 03-05-92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's
+
+Revision History:
+
+ Brian Lieuallen BrianLie 07/21/92
+ Made it work.
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+--*/
+
+
+
+// INCLUDES
+#include <ndis.h>
+#include <efilter.h>
+
+#include "niudata.h"
+#include "debug.h"
+
+#include "ubhard.h"
+#include "ubsoft.h"
+#include "ubnei.h"
+
+#include "map.h"
+
+
+
+
+// INCLUDES:END
+
+
+
+
+
+
+UCHAR
+CardMapRegisterValue(
+ IN PUBNEI_ADAPTER pAdapter,
+ IN ULONG SegAddress
+ );
+
+
+BOOLEAN
+Reset_GPCNIU(
+ OUT PUBNEI_ADAPTER pNewAdapt
+ );
+
+BOOLEAN
+Run_NIU_Diagnostics(
+ OUT PUBNEI_ADAPTER pNewAdapt
+ );
+
+BOOLEAN
+Halt_NIU(
+ OUT PUBNEI_ADAPTER pNewAdapt
+ );
+
+BOOLEAN
+Reset_OtherNIU(
+ OUT PUBNEI_ADAPTER pNewAdapt
+ );
+
+BOOLEAN
+ReadStationAddress(
+ OUT PUBNEI_ADAPTER pNewAdapt
+ );
+
+BOOLEAN
+CardTestMemory(
+ IN PUBNEI_ADAPTER pAdapter
+ );
+
+BOOLEAN
+CardCodeDataInit(
+ OUT PUBNEI_ADAPTER pAdapter
+ );
+
+USHORT
+CardSetMulticast(
+ PUBNEI_ADAPTER pAdapter,
+ PUCHAR MulticastList,
+ UINT ListSize
+ );
+
+
+#ifdef ALLOC_PRAGMA
+#pragma NDIS_INIT_FUNCTION(Reset_GPCNIU)
+#pragma NDIS_INIT_FUNCTION(Run_NIU_Diagnostics)
+#pragma NDIS_INIT_FUNCTION(Halt_NIU)
+#pragma NDIS_INIT_FUNCTION(Reset_OtherNIU)
+#pragma NDIS_INIT_FUNCTION(ReadStationAddress)
+#pragma NDIS_INIT_FUNCTION(CardTestMemory)
+#pragma NDIS_INIT_FUNCTION(CardCodeDataInit)
+#pragma NDIS_INIT_FUNCTION(CardTest)
+#pragma NDIS_INIT_FUNCTION(CardSetup)
+#pragma NDIS_INIT_FUNCTION(CardStartNIU)
+#pragma NDIS_INIT_FUNCTION(CardMapRegisterValue)
+#endif
+
+
+
+
+
+// GLOBAL VARIABLES
+extern UCHAR GPNIU_IRQ_Selections[];
+
+
+extern NIUDETAILS NiuDetails[6];
+
+
+
+
+
+
+BOOLEAN
+CardSetup (
+ OUT PUBNEI_ADAPTER pAdapter
+ )
+/*++
+
+ Routine Description:
+
+ Set up the receive buffers and the various descriptors
+ Set the various statistics and fields assocated with the
+ receive buffers
+
+ Set up the Transmit buffers and the various descriptors
+ Set the various statistics and fields assocated with the
+ transmit buffers
+
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+{
+ ULONG tempLong;
+
+
+/*
+ This set of code was used to make sure that the offsets to these structure
+ elements match the offsets that the assembler created for the data segments
+ of the down load code
+
+
+ PLOWNIUDATA pTest;
+ PHIGHNIUDATA pTest2;
+
+ pTest->sst.SST_MediaSpecificStatisticsPtr=0l;
+ pTest->mst.MST_TableSize=0;
+ pTest->dummy_RDB[0]=(UCHAR)0;
+ pTest->dummy_buffer[0]=(UCHAR)0;
+ pTest->Start_Here[0]=(UCHAR)0;
+
+ pTest2->System_State=0;
+ pTest2->Next_Unused_Location_in_1st_32K=0;
+ pTest2->Stack_Area[0]=0;
+ pTest2->NOP_command[0]=0;
+ pTest2->Configure_with_Loopback[0]=0;
+ pTest2->Dynamically_Allocated_Area[0]=0;
+*/
+
+ pAdapter->pDataWindow=(PHIGHNIUDATA)((PUCHAR)pAdapter->pCardRam+(0x8000 & pAdapter->WindowMask));
+ IF_INIT_LOUD (DbgPrint("Card Data segment is at 0x%lx\n",pAdapter->pDataWindow);)
+
+ pAdapter->pNIU_Control=(PNIU_CONTROL_AREA)((PUCHAR)pAdapter->pCardRam+(0xff00 & pAdapter->WindowMask));
+
+ IF_INIT_LOUD (DbgPrint("Card Control area is at 0x%lx\n",pAdapter->pNIU_Control);)
+
+ //
+ // Setting Initialization Window Base
+ //
+
+ switch ( NiuDetails[pAdapter->AdapterType].AdapterClass ) {
+
+ case CHAMELEON:
+
+
+ //
+ // Set the NIU base address of the shared memory window.
+ //
+ // NIUps memory window can be any where in first 16 Meg
+ //
+
+ if ( pAdapter->AdapterType == NIUPS) {
+ IF_INIT_LOUD( DbgPrint("Set Window base bits 23-20 to %02x\n",(UCHAR)((pAdapter->MemBaseAddr & 0x00F00000) >> 20));)
+
+ NdisRawWritePortUchar(
+ (PUCHAR)pAdapter->SetWindowBasePort+1,
+ (UCHAR)((pAdapter->MemBaseAddr & 0x00F00000) >> 20)
+ );
+ }
+
+ //
+ // Set the low bits for both NIUps and EOTP
+ //
+ IF_INIT_LOUD( DbgPrint("Set Window base bits 19-14 to %02x\n",(UCHAR)((pAdapter->MemBaseAddr & 0x000fc000) >> 12));)
+
+ NdisRawWritePortUchar(
+ pAdapter->SetWindowBasePort,
+ (UCHAR)((pAdapter->MemBaseAddr & 0x000Fc000) >> 12)
+ );
+
+
+
+ //
+ // Enable the GPCNIU adapter.
+ //
+ if ( pAdapter->AdapterType == GPCNIU ) {
+
+ IF_INIT_LOUD( DbgPrint("Enable the EOTP adapter\n");)
+ NdisRawWritePortUchar(
+ pAdapter->InterruptStatusPort,
+ 0x01
+ );
+ }
+ break;
+
+ default :
+ break;
+
+ }
+
+
+ //
+ // Set up the following 4 windows in the NIU Window area
+ //
+ // The Initialization
+ // The ReceiveData
+ // The TransmitData
+ // The Code Window
+ //
+
+
+
+ //
+ // InitWindow Page Map
+ //
+ tempLong=((((ULONG)NiuDetails[pAdapter->AdapterType].HighestRamSegment<<4)+0x10000)-pAdapter->WindowSize)>>4;
+
+ pAdapter->InitWindow_Page = CardMapRegisterValue(pAdapter,tempLong);
+
+ IF_INIT_LOUD (DbgPrint("Init page is 0x%x\n",pAdapter->InitWindow_Page );)
+
+ //
+ // ReceiveWindow Page
+ //
+
+ pAdapter->ReceiveDataWindow_Page =
+ CardMapRegisterValue(pAdapter,
+ NiuDetails[pAdapter->AdapterType].PrimaryDataSegment);
+
+
+ IF_INIT_LOUD (DbgPrint("Rec page is 0x%x\n",pAdapter->ReceiveDataWindow_Page );)
+ //
+ // DataWindow Page
+ //
+
+ pAdapter->DataWindow_Page =
+ CardMapRegisterValue(pAdapter,
+ NiuDetails[pAdapter->AdapterType].PrimaryDataSegment+0x800);
+
+
+ IF_INIT_LOUD (DbgPrint("data page is 0x%x\n",pAdapter->DataWindow_Page);)
+ //
+ // CodeWindow Page
+ //
+
+ pAdapter->CodeWindow_Page =
+ CardMapRegisterValue(pAdapter,
+ NiuDetails[pAdapter->AdapterType].OperationalCodeSegment);
+
+ IF_INIT_LOUD (DbgPrint("code page is 0x%x\n",pAdapter->CodeWindow_Page);)
+
+
+ //
+ // Final Map of the window pages on the 512K Adapter RAM
+ //
+ // (CONTROL REGISTER 1 WINDOW MAP)
+ // 00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78 80
+ // ---------------------------------------------------------------
+ // | | | | | | | | | | | | | |
+ // | | | | |CW |CW |RDW |DW | | | | |IW |
+ // | | | | | | | | | | | | | |
+ // ---------------------------------------------------------------
+ // 0 32 64 96 128 160 192 224 256 288 320 352 384 416 448 480 512
+ // (K)
+
+ return TRUE;
+
+
+
+}
+
+
+UCHAR
+CardMapRegisterValue(
+ IN PUBNEI_ADAPTER pAdapter,
+ IN ULONG SegAddress
+ )
+{
+ UCHAR tempByte;
+
+ tempByte=(UCHAR)((SegAddress<<4)/NiuDetails[pAdapter->AdapterType].MinimumWindowSize);
+ return NiuDetails[pAdapter->AdapterType].MappingTable[tempByte] & ~INTERRUPT_ENABLED;
+}
+
+
+
+
+
+
+
+BOOLEAN
+CardTest (
+ OUT PUBNEI_ADAPTER pAdapter
+ )
+/*++
+
+ Routine Description:
+
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+{
+
+
+ BOOLEAN bResult;
+
+ //
+ // Set up the Initialization area on the RAM
+ //
+
+ SET_INITWINDOW(pAdapter,0);
+
+
+ bResult=FALSE;
+ if (pAdapter->AdapterType==GPCNIU) {
+ if (!(bResult=Reset_GPCNIU(pAdapter))) {
+ IF_INIT_LOUD (DbgPrint("CardTest(): Reset_GPCNIU() failed trying one more time\n");)
+ if (!(bResult=Reset_GPCNIU(pAdapter))) {
+ IF_INIT_LOUD (DbgPrint("CardTest(): Reset_GPCNIU() failed again! all over\n");)
+ return FALSE;
+ }
+ }
+ }
+
+
+ if ( !bResult ||( pAdapter->AdapterType != GPCNIU )) {
+ Reset_OtherNIU(pAdapter);
+ }
+
+
+ //
+ // If this is an EOTP see if the user wants to run diagnostics
+ //
+ if ((pAdapter->AdapterType!=GPCNIU) ||
+ (pAdapter->Diagnostics)) {
+
+ if (!Run_NIU_Diagnostics(pAdapter))
+ return FALSE;
+ }
+
+
+ if (!Halt_NIU(pAdapter))
+ return FALSE;
+
+
+ if (!ReadStationAddress(pAdapter))
+ return FALSE;
+
+
+ if (!CardTestMemory(pAdapter))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+
+
+
+BOOLEAN
+Reset_GPCNIU(
+ OUT PUBNEI_ADAPTER pAdapter
+ )
+/*++
+
+ Routine Description:
+
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+
+{
+
+ PNIU_CONTROL_AREA volatile pNIU_Control = pAdapter->pNIU_Control;
+ ULONG i;
+ USHORT TmpUshort;
+
+
+ //
+ // Reset the NIU, to make it start running the PROM
+ // code. First hold the RESET line high
+ //
+ NdisRawWritePortUchar(
+ pAdapter->MapPort,
+ RESET_SET
+ );
+
+ //
+ // Wait for 1 millisecond
+ //
+ NdisStallExecution( (UINT)2000 );
+
+
+ //
+ // Take RESET down
+ // Wait a while again.
+ NdisRawWritePortUchar(
+ pAdapter->MapPort,
+ RESET_CLEAR
+ );
+
+ NdisStallExecution( (UINT)2000 );
+
+
+ //
+ // GPCNIUs require handshaking with the PROM immediately
+ // after a reset. This is because the SIF chip *always*
+ // enables the RIPL window regardless of what the dip
+ // switches on the board are set to. To get around this,
+ // the RAMs are *disabled* completely until we do the
+ // following handshake to inform the PROM that we have
+ // now disabled the RIPL window from the PC's side.
+ //
+
+ //
+ // 1: Select "Interrupt B"
+ // We're about to write 10000001b to the GPCNIU's
+ // "Window Size, Interrupt Selection, and feature
+ // enables" register. This selects "IRQB", specifies
+ // 32K window size, disables the IPL, IBM 3278/9, and
+ // IRMA features, and leaves the adapter enabled.
+ //
+
+ NdisRawWritePortUchar(
+ pAdapter->InterruptStatusPort,
+ 0x81
+ );
+
+ //
+ // 2: Enable interrupts
+ //
+
+ //
+ // Set the cards window and our shadow register to match
+ // so the debug code won't break
+ //
+ NdisRawWritePortUchar(
+ pAdapter->MapPort,
+ pAdapter->InitWindow_Page
+ );
+
+ pAdapter->MapRegSync.CurrentMapRegister=pAdapter->InitWindow_Page;
+
+ SET_INITWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ //
+ // 3: Wait for the PROM to ack with HWresult2 = 0xAA
+ // We wait up to 1 second. Trials seem to show that
+ // the actual time required is between 650 and 700
+ // milliseconds.
+
+ //
+ // Wait for the transmission to complete, for about a second.
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pNIU_Control->us_HWresult2));
+
+ for (i=0;(i<1500) && (TmpUshort != (USHORT)0xAA);i++) {
+
+ NdisStallExecution( 1000 );
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pNIU_Control->us_HWresult2));
+
+ }
+
+ if (TmpUshort != (USHORT)0xAA) {
+
+ IF_INIT_LOUD (DbgPrint("Reset_GPCNIU: Timer expired waiting for reset\n");)
+ goto fail00;
+
+ }
+
+
+ //
+ // 4: Give the PROM a Halt Command.
+ //
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_HWcommand), 0x1);
+
+
+ //
+ // 5: Wait for the PROM to ack with HWresult2 = 0x55
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pNIU_Control->us_HWresult2));
+
+ for (i=0;(i<500) && (TmpUshort != (USHORT)0x55);i++) {
+
+ NdisStallExecution( 1000 );
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pNIU_Control->us_HWresult2));
+
+ }
+
+ if (TmpUshort != (USHORT)0x55) {
+ IF_INIT_LOUD (DbgPrint("Reset_GPCNIU: Timer expired waiting for halt\n");)
+ goto fail00;
+ }
+
+
+ //
+ // 6: Clear the interrupt (that never really happened)
+ //
+
+ SET_INITWINDOW(pAdapter,INTERRUPT_DISABLED);
+
+ //
+ // 7: Select "Interrupt A"
+ //
+
+ NdisRawWritePortUchar(
+ pAdapter->InterruptStatusPort,
+ 0x01
+ );
+
+
+ return TRUE;
+
+fail00:
+ // clear the interrupt
+ SET_INITWINDOW(pAdapter,INTERRUPT_DISABLED);
+
+ // enable IRQA
+
+ NdisRawWritePortUchar(
+ pAdapter->InterruptStatusPort,
+ 0x01
+ );
+
+ return FALSE;
+
+}
+
+
+
+BOOLEAN
+Reset_OtherNIU(
+ OUT PUBNEI_ADAPTER pAdapter
+ )
+/*++
+
+ Routine Description:
+
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+
+{
+
+ PNIU_CONTROL_AREA volatile pNIU_Control = pAdapter->pNIU_Control;
+ PUSHORT POD_Status_Address;
+
+
+ POD_Status_Address = (PUSHORT)((PUCHAR)pAdapter->pCardRam+
+ (NiuDetails[pAdapter->AdapterType].POD_Status_Address & pAdapter->WindowMask));
+
+ SET_INITWINDOW(pAdapter,0);
+
+ //
+ // Zero out a couple of locations in which the
+ // PROM code will report the results of its
+ // initialization and diagnostics.
+ //
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(POD_Status_Address, 0x0);
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_HWcommand), 0x0);
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_HWresult1), 0x0);
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_HWresult2), 0x0);
+
+ //
+ // We reset the NIU, to make it start running the
+ // PROM code. First we hold the RESET line high
+ // (or whatever it is ) for a while.
+ //
+
+
+ SET_INITWINDOW(pAdapter,RESET_SET);
+
+
+ NdisStallExecution( (UINT)1000 );
+
+ //
+ // Take RESET down (or whatever it is), and wait
+ // a while again.
+ //
+
+ SET_INITWINDOW(pAdapter,RESET_CLEAR);
+
+
+ NdisStallExecution( (UINT)500000 );
+
+ return TRUE;
+}
+
+
+
+
+
+BOOLEAN
+Run_NIU_Diagnostics(
+ OUT PUBNEI_ADAPTER pAdapter
+ )
+/*++
+
+ Routine Description:
+
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+
+{
+
+ PNIU_CONTROL_AREA volatile pNIU_Control = pAdapter->pNIU_Control;
+ PUCHAR POD_status_address;
+
+ UCHAR PODStatus;
+ ULONG i;
+ ULONG ulPassesNeeded;
+ ULONG ulDiagnosticPass;
+
+ UCHAR TmpUchar;
+ USHORT HWResult1;
+
+ POD_status_address = (PUCHAR)pAdapter->pCardRam+
+ (NiuDetails[pAdapter->AdapterType].POD_Status_Address & pAdapter->WindowMask);
+
+ //
+ // Some NIUs will run all their diagnostics as a result of the reset
+ // we just did. Others do some initialization but don't run their full
+ // set of tests. For these latter, we first wait for them to respond
+ // to the reset then we tell them to run their diagnostics, and wait
+ // again for them to report the results.
+ //
+
+ //
+ // We re-map, and wait for the PROM code to finish and report its result.
+ // We wait for up to 20 seconds. The way the PROM diagnostic test progress
+ // and result is reported is different for different kinds of NIUs.
+ // The test codes are all less than 80h (i.e., no code has the high order
+ // bit set). If a test fails, either
+ // (a) the test is repeated indefinitely or
+ // (b) a failure code
+ // is stored into 3FEF8h, replacing the test code, and diagnostics are
+ // terminated.
+ // In case (a), we'll know that the diagnostics failed because
+ // our timer will expire. Failure codes all have the 80h bit set, so we
+ // can detect case (b) by checking the 80h bit in location 3FEF8h. If all
+ // the diagnostic tests run successfully, the success code, AAh, will be
+ // stored in 3FEF8h and also in the "HWresult1" byte (at 3FF94). For NIUs
+ // other than the Atlanta cards, the bytes in which the diagnostic status
+ // and result codes are reported are at different addresses. They are in
+ // different segments, and the "FEF8" one is at different offsets.
+
+
+ IF_INIT_LOUD (DbgPrint("Begin adapter diag\n");)
+
+ ulPassesNeeded=1;
+
+ if ( NiuDetails[pAdapter->AdapterType].AdapterFlags & TWO_PASS_DIAGNOSTICS ) {
+
+ ulPassesNeeded++;
+ }
+
+ ulDiagnosticPass=0;
+
+ SET_INITWINDOW(pAdapter,0);
+
+ for (i=0; i < 20000; i++) {
+
+
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&PODStatus, (PUCHAR)(POD_status_address));
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&HWResult1, &(pNIU_Control->us_HWresult1));
+
+ if ( (PODStatus & 0x80) &&
+ ( PODStatus != 0xff ) &&
+ ( PODStatus == (UCHAR)HWResult1 )) {
+
+
+ // Final check
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar, (PUCHAR)(POD_status_address));
+
+ if ( PODStatus == TmpUchar ) {
+
+ if (PODStatus==0xaa) {
+ ulDiagnosticPass++;
+
+ IF_INIT_LOUD ( DbgPrint("Run_NIU_Diag: Adapter competed first pass pod=%02x HwR=%02x\n",PODStatus,HWResult1);)
+
+ if (ulDiagnosticPass==ulPassesNeeded) {
+
+ IF_INIT_LOUD ( DbgPrint("Run_NIU_Diag: Adapter competed second pass\n");)
+ return TRUE;
+
+ } else {
+ //
+ // Requires second set of diagnostics to be run
+ //
+
+ //
+ // Give the PROM code an "INTERRUPT" command
+ //
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM((PUCHAR)(POD_status_address), 0x0);
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_HWcommand), 14);
+
+ //
+ // Wait for it to respond.
+ //
+ NdisStallExecution ( (UINT)250000 );
+
+ //
+ // Issue the DIAG command to the prom
+ //
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM((PUCHAR)(POD_status_address), 0xFF);
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_HWresult1), 0);
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_HWcommand), 3);
+
+ }
+
+ } else {
+ IF_INIT_LOUD ( DbgPrint("Run_NIU_DIAG: Adapter returned fail code\n");)
+ return FALSE;
+
+ }
+
+ }
+
+ } else {
+ //
+ // Not a complete status, wait some more
+ //
+
+ NdisStallExecution( 1000 );
+ }
+
+ }
+
+ IF_INIT_LOUD ( DbgPrint("Run_NIU_Diag: Adapter failed to complete Diag\n");)
+ return FALSE;
+
+}
+
+
+BOOLEAN
+Halt_NIU(
+ OUT PUBNEI_ADAPTER pAdapter
+ )
+/*++
+
+ Routine Description:
+
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+
+{
+ PNIU_CONTROL_AREA volatile pNIU_Control = pAdapter->pNIU_Control;
+ ULONG i, LoopLimit;
+ USHORT TmpUshort;
+
+
+ switch ( NiuDetails[pAdapter->AdapterType].AdapterClass ) {
+
+ case CHAMELEON:
+
+ SET_INITWINDOW(pAdapter,0);
+
+ LoopLimit = 5000;
+
+ //
+ // issue attention command
+ //
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_HWcommand), 13);
+
+ break;
+
+ case ATLANTA:
+ SET_INITWINDOW(pAdapter,0);
+ LoopLimit = 500;
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(
+ (PUSHORT)((PUCHAR)pAdapter->pCardRam+(0xfefa & pAdapter->WindowMask)),
+ 0x5A5A);
+
+ break;
+
+
+ default :
+ break;
+ }
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pNIU_Control->us_HWcommand));
+
+ for (i=0;(i<LoopLimit) && ( TmpUshort != 1 );i++) {
+
+ NdisStallExecution( 1000 );
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pNIU_Control->us_HWcommand));
+
+ }
+
+ if ( TmpUshort != 1 ) {
+ //
+ // NIU Failed to halt
+ //
+ IF_INIT_LOUD (DbgPrint("Halt_NIU: The Adapter Failed to halt\n");)
+ return FALSE;
+
+ } else {
+ IF_INIT_LOUD (DbgPrint("Halt_NIU: The Adapter halted properly\n");)
+ return TRUE;
+ }
+
+
+
+}
+
+
+BOOLEAN
+ReadStationAddress(
+ OUT PUBNEI_ADAPTER pAdapter
+ )
+/*++
+
+ Routine Description:
+ Read the station address from the NIU control data at the top of
+ the cards RAM
+
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+
+{
+
+ PNIU_CONTROL_AREA pNIU_Control = pAdapter->pNIU_Control;
+
+ SET_INITWINDOW(pAdapter,0);
+
+ // while we are looking at the init window, we will get the station address
+
+ IF_INIT_LOUD( DbgPrint("The Station address is ");)
+
+ UBNEI_MOVE_SHARED_RAM_TO_MEM(pAdapter->PermanentAddress,
+ (PUCHAR)pNIU_Control->uc_node_id,
+ ETH_LENGTH_OF_ADDRESS
+ );
+
+#if DBG
+
+ {
+ UINT i;
+
+ for (i=0;i<ETH_LENGTH_OF_ADDRESS;i++) {
+
+ IF_INIT_LOUD( DbgPrint(" %02X",pAdapter->PermanentAddress[i]); )
+
+ }
+ }
+
+#endif
+
+ IF_INIT_LOUD( DbgPrint("\n");)
+
+ //
+ // One time the card initialized with the wrong station address
+ // so as a little extra check we will make sure the card has a UB OEM #
+ //
+
+ if (!(pAdapter->PermanentAddress[0]==0x00 &&
+ pAdapter->PermanentAddress[1]==0xdd &&
+ (pAdapter->PermanentAddress[2]==0x01 ||
+ pAdapter->PermanentAddress[2]==0x00))) {
+ IF_INIT_LOUD( DbgPrint("The Station address does not match a UB address\n");)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+BOOLEAN
+CardTestMemory(
+ IN PUBNEI_ADAPTER pAdapter
+ )
+/*++
+
+ Routine Description:
+ Tests the card memory to try to see if there are any mapping
+ conflicts with the map window. Basically it makes sure the
+ is ram for the whole map window
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+
+{
+ PULONG p;
+ UINT i;
+ BOOLEAN Result=TRUE;
+ ULONG TmpUlong;
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: CardTestMemory\n");)
+
+ //
+ // first switch to the code window and write our pattern
+ //
+ SET_CODEWINDOW(pAdapter,0);
+
+ p=(PULONG)pAdapter->pCardRam;
+ for (i=0;i<(pAdapter->WindowSize/4);i++) {
+
+ UBNEI_MOVE_DWORD_TO_SHARED_RAM(p+i, 0x0F55CCF0);
+
+ }
+
+ //
+ // switch to the data window and zero it out.
+ //
+ SET_RECDWINDOW(pAdapter,0);
+
+ for (i=0;i<(pAdapter->WindowSize/4);i++) {
+
+ UBNEI_MOVE_DWORD_TO_SHARED_RAM(p+i, 0x0);
+
+ }
+
+ //
+ // Back to the code window and make sure the pattern is still there
+ //
+ SET_CODEWINDOW(pAdapter,0);
+
+ for (i=0;i<(pAdapter->WindowSize/4);i++) {
+
+ UBNEI_MOVE_SHARED_RAM_TO_DWORD(&TmpUlong, p+i);
+
+ if (TmpUlong != 0x0F55CCF0) {
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: CardTestMemory() Failed @ %0x Found %0lx\n",i,*(p+i));)
+
+ Result = FALSE;
+
+ break;
+
+ }
+
+ }
+
+ return Result;
+
+}
+
+
+BOOLEAN
+CardCodeDataInit(
+ OUT PUBNEI_ADAPTER pAdapter
+ )
+
+/*++
+
+ Routine Description:
+ This routine initializes various things in the NIU codes
+ data segment and actaully copies the NIU code to the card
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+{
+ PLOWNIUDATA pRcvDWindow = (PLOWNIUDATA) pAdapter->pCardRam;
+ PHIGHNIUDATA pDataWindow = (PHIGHNIUDATA) pAdapter->pDataWindow;
+ PNIU_CONTROL_AREA pNIU_Control = pAdapter->pNIU_Control;
+ UINT AdapterType = pAdapter->AdapterType;
+ UCHAR uc_Byte;
+ USHORT TmpUshort;
+
+ NDIS_HANDLE FileHandle;
+ UINT FileLength;
+ NDIS_STATUS Status;
+ PVOID ImageBuffer;
+
+
+ NDIS_STRING FileName=NDIS_STRING_CONST("ubnei.bin");
+
+
+ //
+ // Set the RcvDataWindow Page in place.
+ //
+
+ SET_RECDWINDOW(pAdapter,INTERRUPT_DISABLED);
+
+
+ // Zero out the first "page" of the lower 32k of the NIU code's main
+ // data segment. if there's room).
+ //
+ NdisZeroMappedMemory ( pAdapter->pCardRam, pAdapter->WindowSize);
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pRcvDWindow->mst.MST_TableSize), sizeof(MediaStatistics));
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pRcvDWindow->mst.MST_StructureVersionLevel), 1);
+
+ UBNEI_MOVE_DWORD_TO_SHARED_RAM(&(pRcvDWindow->mst.MST_LateCollisions), 0xFFFFFFFF);
+ UBNEI_MOVE_DWORD_TO_SHARED_RAM(&(pRcvDWindow->mst.MST_JabberErrors), 0xFFFFFFFF);
+ UBNEI_MOVE_DWORD_TO_SHARED_RAM(&(pRcvDWindow->mst.MST_CarrierSenseLostDuringTransmission), 0xFFFFFFFF);
+
+ UBNEI_MOVE_DWORD_TO_SHARED_RAM(&(pRcvDWindow->sst.SST_FramesSmallerThanMinimumSize), 0xFFFFFFFF);
+ UBNEI_MOVE_DWORD_TO_SHARED_RAM(&(pRcvDWindow->sst.SST_MediaSpecificStatisticsPtr), 0);
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pRcvDWindow->InterruptDisabled), 0xFF);
+
+ //
+ // Now switch to the DataWindow Page
+ //
+ SET_DATAWINDOW(pAdapter,INTERRUPT_DISABLED);
+
+
+ //
+ // Zero out up til end of Data Window
+ //
+ NdisZeroMappedMemory ( pAdapter->pCardRam, sizeof(HIGHNIUDATA));
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->NIU_AdapterType), AdapterType);
+
+ if ( NiuDetails[AdapterType].AdapterFlags & ASYNCHRONOUS_READY ) {
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pDataWindow->System_Modes));
+
+ TmpUshort |= INTERNAL_READY_SYNC;
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->System_Modes), TmpUshort);
+
+ }
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->LED_Off_12Volts_DoParityCheck),
+ NiuDetails[AdapterType].LED_Off_12Volts_DoParityCheck
+ );
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->LED_On_12Volts_DoParityCheck),
+ NiuDetails[AdapterType].LED_On_12Volts_DoParityCheck
+ );
+
+ uc_Byte=0;
+
+ if (AdapterType == GPCNIU)
+ uc_Byte=GPNIU_IRQ_Selections[pAdapter->IrqLevel];
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->LED_Off_and_IRQ_Select),
+ uc_Byte
+ );
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->LED_On_and_IRQ_Select),
+ uc_Byte | 1
+ );
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->HostWindowMask),
+ (USHORT)(pAdapter->WindowMask)
+ );
+
+ UBNEI_MOVE_DWORD_TO_SHARED_RAM(&(pDataWindow->HostWindowSize),
+ (ULONG)(pAdapter->WindowSize)
+ );
+
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->_82586_CA_Address),
+ (USHORT)(NiuDetails[AdapterType]._82586_CA_Port)
+ );
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->_82586_RESET_Address),
+ (USHORT)(NiuDetails[AdapterType]._82586_RESET_Port)
+ );
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->HostInterruptPort),
+ (USHORT)(NiuDetails[AdapterType].HostInterruptPort)
+ );
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->AdapterControlPort),
+ (USHORT)(NiuDetails[AdapterType].AdapterControlPort)
+ );
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->IRQ_Select_and_LED_Port),
+ (USHORT)(NiuDetails[AdapterType].IRQ_Select_And_LED_Port)
+ );
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->DeadmanTimerPort),
+ (USHORT)(NiuDetails[AdapterType].DeadManTimerPort)
+ );
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Xmt_Timeout), 1000);
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Diagnostic_Timeout), 2000);
+ // UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Xmt_Buffer_Start), 80);
+
+
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM((&pDataWindow->Default_Address_Base.u.SegOff.Segment),
+ (NiuDetails[AdapterType].SCPSegment)
+ );
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Default_Address_Base.u.SegOff.Offset),
+ (0xfff0)
+ );
+
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM((&pDataWindow->SCP_Base.u.SegOff.Offset),
+ 0xfff6
+ );
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM((&pDataWindow->SCP_Base.u.SegOff.Segment),
+ (NiuDetails[AdapterType].SCPSegment)
+ );
+
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Max_Multicast_Addresses),
+ pAdapter->MaxMultiCastTableSize
+ );
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Max_General_Requests),
+ pAdapter->MaxRequests
+ );
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Rcv_Buffer_Size),
+ pAdapter->ReceiveBufSize
+ );
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Code_and_Xmt_Segment),
+ NiuDetails[AdapterType].OperationalCodeSegment
+ );
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Xmt_Buffer_Size), 1514);
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Max_Receive_Size), 1514);
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Min_Receive_Size), 60);
+
+ //
+ // user definable things from dos driver, using the defaults
+ //
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Rcv_Timeout), 10000);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_FIFO_Threshold), 15);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_PreambleLength), 2);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_CRC_Polynomial), 0);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_InterframeSpacing), 96);
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->user_SlotTime), 512);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_MaxRetries), 15);
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Max_Collisions), 16);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_LinearPriority), 0);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_ACR_Priority), 0);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_BackoffMethod), 0);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_CRS_Filter), 0);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_CDT_Filter), 0);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->user_Min_Frame_Length), 60);
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->MinimumHostWindowSize),
+ NiuDetails[AdapterType].MinimumWindowSize
+ );
+
+
+ NdisMoveToMappedMemory((PUCHAR)pDataWindow->Map_Table,NiuDetails[AdapterType].MappingTable,32);
+
+
+
+ NdisOpenFile(
+ &Status,
+ &FileHandle,
+ &FileLength,
+ &FileName,
+ HighestAcceptableMax
+ );
+
+ if (Status==NDIS_STATUS_SUCCESS) {
+
+ NdisMapFile(
+ &Status,
+ &ImageBuffer,
+ FileHandle
+ );
+
+ if (Status==NDIS_STATUS_SUCCESS) {
+
+ SET_CODEWINDOW(pAdapter,0);
+
+ NdisMoveToMappedMemory(pAdapter->pCardRam,ImageBuffer,FileLength);
+
+ SET_DATAWINDOW(pAdapter,INTERRUPT_DISABLED);
+
+ NdisUnmapFile(FileHandle);
+
+ NdisCloseFile(FileHandle);
+
+ return TRUE;
+
+ } else {
+
+ NdisCloseFile(FileHandle);
+
+ return FALSE;
+ }
+
+ }
+
+
+ return FALSE;
+
+}
+
+
+
+BOOLEAN
+CardStartNIU(
+ OUT PUBNEI_ADAPTER pAdapter
+ )
+
+/*++
+
+ Routine Description:
+
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+{
+ PLOWNIUDATA pRcvDWindow = (PLOWNIUDATA) pAdapter->pCardRam;
+ PHIGHNIUDATA pDataWindow = (PHIGHNIUDATA) pAdapter->pDataWindow;
+ PNIU_CONTROL_AREA volatile pNIU_Control = pAdapter->pNIU_Control;
+ ULONG i;
+ BOOLEAN ReturnStatus= TRUE;
+ USHORT TmpUshort;
+
+ USHORT NumberOfXmtBuffers;
+ USHORT SizeOfXmtBuffers;
+
+ USHORT NumberOfRcvBuffers;
+ USHORT SizeOfRcvBuffers;
+
+ //
+ // With interrupts disabled at the card set the flag
+ //
+ NdisMSynchronizeWithInterrupt(
+ &pAdapter->NdisInterrupt,
+ UbneiSetInitInterruptSync,
+ pAdapter
+ );
+
+ //
+ // Init NIU code and data
+ //
+
+ ReturnStatus=CardCodeDataInit(pAdapter);
+
+ if (!ReturnStatus) {
+
+ return FALSE;
+
+ }
+
+
+ SET_DATAWINDOW(pAdapter,INTERRUPT_DISABLED);
+
+ //
+ // This x86 assembly is copied to the data segment of the
+ // niu code. The segment portion of the far jump is fixed up
+ // with the correct segment. The PROM CS:IP in the top of
+ // the init code segment is set to point to the code in the
+ // data segment
+ //
+ // We wait for two things to happen before we decide the the card
+ // has success fully started. One the system state flag must indicated
+ // that the card has initialized and we have to receive and interrupt
+ // from the card. If we do not get an interrupt then the incorrect
+ // interrupt has been selected
+
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->Startup_Code[0]), 0x8C ); // mov ax,cs
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->Startup_Code[1]), 0xC8 );
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->Startup_Code[2]), 0x8E ); // mov ds,ax
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->Startup_Code[3]), 0xD8 );
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->Startup_Code[4]), 0x90 ); // nop
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->Startup_Code[5]), 0xEA ); // jmp far ptr
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->Startup_Code[6]), 0x00 );
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->Startup_Code[7]), 0x00 );
+
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->Startup_Code_CS_fixup),
+ (USHORT)NiuDetails[pAdapter->AdapterType].OperationalCodeSegment
+ );
+
+ pAdapter->uInterruptCount=0;
+
+ SET_INITWINDOW(pAdapter,0);
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_CS_value),
+ NiuDetails[pAdapter->AdapterType].PrimaryDataSegment
+ );
+
+ TmpUshort = (USHORT)(((PUCHAR)pDataWindow->Startup_Code)-(PUCHAR)pDataWindow)+0x8000;
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_IP_value), TmpUshort);
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: down load cs:ip %04x:%04x\n",NiuDetails[pAdapter->AdapterType].PrimaryDataSegment, TmpUshort);)
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pNIU_Control->us_HWcommand), 2);
+
+ SET_DATAWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ //
+ // Wait until the system state is initialized and the interrupt has come
+ // through
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pDataWindow->System_State));
+
+ for (i=0;(i<1000) && !((TmpUshort & INITIALIZED) && (pAdapter->uInterruptCount!=0)); i++) {
+ NdisStallExecution(1000);
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pDataWindow->System_State));
+ }
+
+ if (!((TmpUshort & INITIALIZED) )) {
+ IF_INIT_LOUD( DbgPrint("CardStartNIU: NIU code did not init sys=%04x\n",TmpUshort);)
+ ReturnStatus=FALSE;
+ } else {
+ IF_INIT_LOUD (DbgPrint("CardStartNIU: NIU code Initialized sys=%04x\n",TmpUshort);)
+ }
+
+
+ SET_DATAWINDOW(pAdapter,INTERRUPT_DISABLED);
+
+ NdisMSynchronizeWithInterrupt(
+ &pAdapter->NdisInterrupt,
+ UbneiSetNormalInterruptSync,
+ pAdapter
+ );
+
+ if (pAdapter->uInterruptCount==0) {
+
+ IF_INIT_LOUD( DbgPrint("Did not get interrupt from NIU code\n");)
+
+ NdisWriteErrorLogEntry(pAdapter->NdisAdapterHandle,
+ NDIS_ERROR_CODE_INTERRUPT_CONNECT,
+ 1,
+ (ULONG)pAdapter->IrqLevel
+ );
+
+ ReturnStatus=FALSE;
+ }
+
+ if (ReturnStatus) {
+ //
+ // Calulate some statistics from info filled in by the NIU code
+ //
+
+ SET_DATAWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&NumberOfXmtBuffers, &pDataWindow->Number_of_Xmt_Buffers);
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&SizeOfXmtBuffers, &pDataWindow->Xmt_Buffer_Size);
+
+ pAdapter->TransmitBufferSpace=NumberOfXmtBuffers * SizeOfXmtBuffers;
+
+ IF_INIT_LOUD(DbgPrint("TransmitBufferSpace %d\n",pAdapter->TransmitBufferSpace);)
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&NumberOfRcvBuffers, &pDataWindow->Number_of_Rcv_Buffers);
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&SizeOfRcvBuffers, &pDataWindow->Rcv_Buffer_Size);
+
+
+ pAdapter->ReceiveBufferSpace=NumberOfRcvBuffers * SizeOfRcvBuffers;
+
+ IF_INIT_LOUD(DbgPrint("ReceiveBufferSpace %d\n",pAdapter->ReceiveBufferSpace);)
+
+ pAdapter->TransmitBlockSize=SizeOfXmtBuffers;
+
+ pAdapter->ReceiveBlockSize=SizeOfRcvBuffers;
+
+ }
+
+ SET_RECDWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pRcvDWindow->InterruptDisabled),0x00);
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pRcvDWindow->InterruptActive),0x00);
+
+ return ReturnStatus;
+
+}
+
+
+
+
+
+
+
+
+BOOLEAN
+NIU_General_Request3(
+ IN NIU_GEN_REQ_DPC pDPCCallback,
+ IN PVOID pContext,
+ IN USHORT RequestCode,
+ IN USHORT param1,
+ IN PUCHAR param2
+ )
+
+/*++
+
+ Routine Description:
+ This routine adds a general request to a general request queue
+ for later processing. During the interrupt DPC the request will actually
+ be sent to the card for processing. Also during the interrupt DPC
+ the requests that the card has completed will indicated.
+
+ NOTE: This code assumes that the spin lock is held
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+{
+ PUBNEI_ADAPTER pAdapt = pContext;
+ PLOWNIUDATA pRcvDWindow = (PLOWNIUDATA) pAdapt->pCardRam;
+ PHIGHNIUDATA pDataWindow = (PHIGHNIUDATA) pAdapt->pDataWindow;
+
+
+ USHORT RequestID,i;
+ PNIUREQUEST pRequestBlock;
+
+ IF_REQ_LOUD (DbgPrint("NIU_General_Request cmd=%d\n",RequestCode);)
+
+ IF_LOG('3');
+
+ IF_LOG((UCHAR)(RequestCode+'0'));
+
+ if (pAdapt->NIU_Requests_Pending >= pAdapt->MaxRequests) {
+ IF_REQ_LOUD (DbgPrint("NIU_General_Request: Fail--Too many request pending\n");)
+ return FALSE;
+ }
+
+
+ RequestID=pAdapt->NIU_Request_Head;
+
+ pRequestBlock=&pAdapt->NiuRequest[RequestID];
+
+ pAdapt->NIU_Requests_Pending++;
+ pAdapt->NIU_Request_Head=(pAdapt->NIU_Request_Head+1)%pAdapt->MaxRequests;
+
+
+ pRequestBlock->pContext=(PVOID) pContext;
+ pRequestBlock->pDPCFunc=pDPCCallback;
+
+ pRequestBlock->AddressList=param2;
+
+ pRequestBlock->rrbe.RequestCode=RequestCode;
+ pRequestBlock->rrbe.RequestParam1=param1;
+
+
+
+ if (RequestCode==3 || RequestCode==9) {
+ //
+ // Set station address
+ //
+ for (i=0;i<6;i++) {
+
+ pRequestBlock->rrbe.RequestData[i]=((UCHAR*)param2)[i];
+
+ }
+ }
+
+
+ NIU_Send_Request_To_Card(pAdapt);
+
+ IF_LOG('3');
+
+ ASSERT_INTERRUPT_ENABLED(pAdapt);
+
+ return TRUE;
+}
+
+
+
+
+
+VOID
+NIU_Send_Request_To_Card(
+ IN PUBNEI_ADAPTER pAdapt
+ )
+/*++
+
+ Routine Description:
+ This routine is called by the interrupt handler DPC to see if any
+ if any general request have been placed on the queue. If there request
+ they are actaully sent to the NIU by manipulating the request ring
+ buffer.
+
+ NOTE: This is called with the lock held!!!
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+
+{
+
+ PLOWNIUDATA pRcvDWindow = (PLOWNIUDATA) pAdapt->pCardRam;
+ PHIGHNIUDATA pDataWindow = (PHIGHNIUDATA) pAdapt->pDataWindow;
+ PORB pORB;
+ PRRBE pRRBE;
+ UCHAR ucTemp,ucTemp2;
+ USHORT usTemp;
+
+ USHORT ORBOffset;
+ USHORT BufferBase;
+ UCHAR WritePtr;
+ UCHAR ElementSize;
+
+ USHORT RequestID,i;
+ PNIUREQUEST pRequestBlock;
+
+ IF_LOG('r');
+
+ while (pAdapt->NIU_Next_Request!=pAdapt->NIU_Request_Head) {
+
+ RequestID=pAdapt->NIU_Next_Request;
+
+ pRequestBlock=&pAdapt->NiuRequest[RequestID];
+
+ // Check to see if a multicast change is already pending
+
+
+ pAdapt->NIU_Next_Request=(pAdapt->NIU_Next_Request+1)%pAdapt->MaxRequests;
+
+ SET_DATAWINDOW_SYNC(pAdapt,INTERRUPT_ENABLED);
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&ORBOffset, &(pDataWindow->Request_RingBuffer));
+
+ pORB=(PORB)((PUCHAR) pAdapt->pCardRam+
+ (ORBOffset & pAdapt->WindowMask));
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&BufferBase, &(pORB->ORB_BufferBase));
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&WritePtr, &(pORB->ORB_WritePtr_Byte));
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&ElementSize, &(pORB->ORB_ElementSize));
+
+
+ pRRBE=(PRRBE)((PUCHAR)pAdapt->pCardRam+
+ (WritePtr*ElementSize+
+ (BufferBase & pAdapt->WindowMask)));
+
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&pRRBE->RequestCode,pRequestBlock->rrbe.RequestCode);
+
+ IF_REQ_LOUD (DbgPrint("NIU_Send_Request_To_Card cmd=%d\n",pRequestBlock->rrbe.RequestCode);)
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&pRRBE->RequestID, RequestID);
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&pRRBE->RequestParam1, pRequestBlock->rrbe.RequestParam1);
+
+ if (pRequestBlock->rrbe.RequestCode==8) {
+
+ usTemp=CardSetMulticast(
+ pAdapt,
+ pRequestBlock->AddressList,
+ pRequestBlock->rrbe.RequestParam1
+ );
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&pRRBE->RequestParam1, usTemp);
+
+ }
+
+
+ if (pRequestBlock->rrbe.RequestCode==3 ||
+ pRequestBlock->rrbe.RequestCode==9) {
+
+ for (i=0;i<6;i++) {
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&pRRBE->RequestData[i], pRequestBlock->rrbe.RequestData[i]);
+
+ }
+ }
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&ucTemp,&pORB->ORB_WritePtr_Byte);
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&ucTemp2,&pORB->ORB_PtrLimit);
+
+ ucTemp++;
+ if (ucTemp>ucTemp2) {
+
+ ucTemp=0;
+ }
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&pORB->ORB_WritePtr_Byte,ucTemp);
+
+ SET_RECDWINDOW_SYNC(pAdapt,INTERRUPT_ENABLED);
+
+ }
+
+ SET_RECDWINDOW_SYNC(pAdapt,INTERRUPT_ENABLED);
+ return;
+
+}
+
+
+
+VOID
+NIU_General_Req_Result_Hand(
+ IN PUBNEI_ADAPTER pAdapt
+ )
+/*++
+
+ Routine Description:
+ This routine is called by the interrupt handler DPC to see if any
+ if any general request have completed. If they have then the
+ DPC will be called
+
+ NOTE: This is called with the lock held!!!
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+
+{
+ PHIGHNIUDATA pDataWindow = (PHIGHNIUDATA) pAdapt->pDataWindow;
+ PORB pORB;
+ PRESULTRBE pRRBE;
+ UCHAR ucTemp;
+ USHORT TmpUshort;
+ UCHAR TmpUchar1, TmpUchar2;
+
+ USHORT ResultID,RequestCode;
+ NDIS_STATUS status;
+ PNIUREQUEST pRequestBlock;
+
+
+
+ if (pAdapt->NIU_Request_Tail==pAdapt->NIU_Next_Request) {
+ //
+ // There aren't any request that have not been completed
+ //
+ IF_REQ_LOUD(DbgPrint("NIU_General_Req_Result_Hand: Nothing to Do\n");)
+ return;
+ }
+
+ //
+ // Now see if any of the requests have completed
+ //
+
+ IF_LOG('h');
+
+ SET_DATAWINDOW(pAdapt,INTERRUPT_ENABLED);
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pDataWindow->Result_RingBuffer));
+
+ pORB=(PORB)((PUCHAR) pAdapt->pCardRam + (TmpUshort & pAdapt->WindowMask));
+
+
+ while (1) {
+
+ SET_DATAWINDOW(pAdapt,INTERRUPT_ENABLED);
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar1, &(pORB->ORB_ReadPtr_Byte));
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar2, &(pORB->ORB_ElementSize));
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pORB->ORB_BufferBase));
+
+ pRRBE=(PRESULTRBE)((PUCHAR)pAdapt->pCardRam+
+ (TmpUchar1 * TmpUchar2 +
+ (TmpUshort & pAdapt->WindowMask)));
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar2, &(pORB->ORB_WritePtr_Byte));
+
+ IF_REQ_LOUD(DbgPrint("UBNEI: NIU_General_Req_Result_Hand: read=%d write=%d\n",TmpUchar1,TmpUchar2);)
+
+ if (TmpUchar1 == TmpUchar2) {
+ //
+ // There aren't any results in the ring buffer, so nothing to do
+ //
+ SET_RECDWINDOW(pAdapt,INTERRUPT_ENABLED);
+ IF_REQ_LOUD(DbgPrint("UBNEI: NIU_General_Req_Result_Hand: No results.\n");)
+ IF_LOG('H');
+ return;
+ }
+
+ //
+ // We found a result in the ring buffer
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pRRBE->ResultCode));
+
+ if (TmpUshort == 0) {
+ status=NDIS_STATUS_SUCCESS;
+ } else {
+ IF_REQ_LOUD(DbgPrint("NIU Gen Req failed\n");)
+ status=NDIS_STATUS_FAILURE;
+ }
+
+ //
+ // The ID is an index into our request array memory block
+ //
+
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&ResultID, &(pRRBE->ResultID));
+
+#if DBG
+ if (ResultID != pAdapt->NIU_Request_Tail) {
+ IF_REQ_LOUD (DbgPrint("ResultID != Request_Tail\n");)
+ }
+#endif
+
+ //
+ // We remove the result from the ring buffer
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&ucTemp, &(pORB->ORB_ReadPtr_Byte));
+
+ ucTemp++;
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar1, &(pORB->ORB_PtrLimit));
+
+ if (ucTemp > TmpUchar1)
+
+ ucTemp=0;
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pORB->ORB_ReadPtr_Byte), ucTemp);
+
+ SET_RECDWINDOW(pAdapt,INTERRUPT_ENABLED);
+
+ pRequestBlock=&pAdapt->NiuRequest[ResultID];
+ RequestCode=pRequestBlock->rrbe.RequestCode;
+
+ IF_REQ_LOUD (DbgPrint("NIU_General_Request_Result_Handler cmd=%d\n",RequestCode);)
+
+ (*pRequestBlock->pDPCFunc)(status,pRequestBlock->pContext);
+
+ pAdapt->NIU_Requests_Pending--;
+ pAdapt->NIU_Request_Tail=(pAdapt->NIU_Request_Tail+1)%pAdapt->MaxRequests;
+
+
+ IF_LOG('c');
+
+ }
+
+ IF_LOG('H');
+
+ return;
+}
+
+
+
+
+USHORT
+CardSetMulticast(
+ PUBNEI_ADAPTER pAdapter,
+ PUCHAR MulticastList,
+ UINT ListSize
+ )
+/*++
+
+ Routine Description:
+ This routine copies the multicast list into the card memory.
+ We copy the list to an area of memory just below the actual
+ multicast address list. When the card code actually processes
+ the request it will copy the list from the location up to the
+ actual location
+
+ Arguments:
+
+
+ Return Value:
+
+
+--*/
+
+{
+ PHIGHNIUDATA pDataWindow = (PHIGHNIUDATA) pAdapter->pDataWindow;
+
+ UINT NumberOfAddress,i;
+ UCHAR TmpUchar;
+
+
+
+ NdisMoveToMappedMemory(
+ (PUCHAR)&pDataWindow->Dynamically_Allocated_Area[pAdapter->MaxMultiCastTableSize],
+ MulticastList,
+ ListSize
+ );
+
+ NumberOfAddress= ListSize / 6;
+
+ // The 82586 seems to have a problem with 3 multicast addresses,
+ // so if the list is 3 long we copy the third one into the forth
+ // place in the list also
+
+ if (NumberOfAddress==3) {
+
+ IF_INIT_LOUD (DbgPrint("CardSetMulticast() padding list to 4 from 3\n");)
+
+ for (i=0;i<6;i++) {
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(
+ &TmpUchar,
+ &(pDataWindow->Dynamically_Allocated_Area[pAdapter->MaxMultiCastTableSize+2][i])
+ );
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(
+ &(pDataWindow->Dynamically_Allocated_Area[pAdapter->MaxMultiCastTableSize+3][i]),
+ TmpUchar
+ );
+
+
+ }
+
+ NumberOfAddress+=1;
+
+ }
+
+ return (NumberOfAddress*ETH_LENGTH_OF_ADDRESS);
+}
diff --git a/private/ntos/ndis/ubnei/config.c b/private/ntos/ndis/ubnei/config.c
new file mode 100644
index 000000000..a63692eb5
--- /dev/null
+++ b/private/ntos/ndis/ubnei/config.c
@@ -0,0 +1,532 @@
+ /*++
+
+Copyright (c) 1992 Microsoft Corporation
+
+Module Name:
+
+ config.c
+
+Abstract:
+
+ This file handles retrieving configration parameters for the card
+ from the registry and from the POS register on an MCA card.
+
+ The following parameters are currently used
+
+ AdapterType= 2,3,4
+
+ if (AdapterType=3) // MCA card
+ SlotNumber = Slot number
+
+ else // ISA card
+ IOAddress = Starting IO base address 350,358,360,368
+ Interrupt = 2,3,4,5,7,9,12 depending on card
+ MemoryWindow = ( c8000, d8000) other valid but not likely
+
+ All adapters
+
+ MaximumMulticastList
+ ReceiveBufferSize (256 >= X >= 1514)
+ MaxOpens
+
+
+
+Author:
+ Brian Lieuallen (BrianLie) 07/02/92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's
+
+Revision History:
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+
+--*/
+
+
+
+#include <ndis.h>
+#include <efilter.h>
+
+#include "niudata.h"
+#include "debug.h"
+#include "ubhard.h"
+#include "ubsoft.h"
+#include "ubnei.h"
+#include "keywords.h"
+
+
+
+extern ULONG MemoryWindows[];
+
+extern ULONG MemoryBases[];
+
+extern USHORT PortBases[];
+
+
+
+#ifdef ALLOC_PRAGMA
+#pragma NDIS_INIT_FUNCTION(UbneiReadRegistry)
+#endif
+
+
+
+
+NDIS_STATUS
+UbneiReadRegistry(
+ IN PUBNEI_ADAPTER pAdapter,
+ IN NDIS_HANDLE ConfigurationHandle
+ )
+
+{
+
+
+ NDIS_HANDLE ConfigHandle;
+ PNDIS_CONFIGURATION_PARAMETER ReturnedValue;
+ NDIS_STRING IOAddressStr = IOADDRESS;
+ NDIS_STRING InterruptStr = INTERRUPT;
+ NDIS_STRING AdapterTypeStr = CARDTYPE;
+ NDIS_STRING MaxMulticastListStr = MAX_MULTICAST_LIST;
+ NDIS_STRING MemWindBaseStr = MEMMAPPEDBASE;
+ NDIS_STRING ReceiveBuffSizeStr = RCVBUFSIZE;
+ NDIS_STRING DiagStr = NDIS_STRING_CONST("Diagnostics");
+ BOOLEAN ConfigError = FALSE;
+ ULONG ConfigErrorValue = 0;
+
+ NDIS_STATUS Status;
+ NDIS_MCA_POS_DATA McaData;
+ UCHAR tempByte;
+ UCHAR NetworkAddress[ETH_LENGTH_OF_ADDRESS] = {0};
+
+ //
+ // These are used when calling UbneiRegisterAdapter.
+ //
+
+
+
+ UINT ChannelNumber = 0;
+ ULONG WindowSize = 0x8000;
+ ULONG IoBaseAddr = DEFAULT_IO_BASEADDRESS;
+ ULONG MemWindBase = DEFAULT_MEMORY_WINDOW;
+ CCHAR InterruptNumber = DEFAULT_INTERRUPT_NUMBER;
+ UINT MaxMulticastList = DEFAULT_MULTICAST_SIZE;
+ UINT ReceiveBuffSize = DEFAULT_RECEIVE_BUFFER_SIZE;
+ UINT MaxRequests = DEFAULT_MAXIMUM_REQUESTS;
+ UINT AdapterType = DEFAULT_ADAPTER_TYPE;
+ UINT MaxOpens = 10;
+ BOOLEAN Diagnostics = TRUE;
+ PVOID NetAddress;
+ ULONG Length;
+ NDIS_INTERRUPT_MODE InterruptMode=NdisInterruptLatched;
+
+ NdisOpenConfiguration(
+ &Status,
+ &ConfigHandle,
+ ConfigurationHandle
+ );
+
+ if (Status != NDIS_STATUS_SUCCESS) {
+
+ return NDIS_STATUS_FAILURE;
+ }
+
+ //
+ // Read net address
+ //
+
+ NdisReadNetworkAddress(
+ &Status,
+ &NetAddress,
+ &Length,
+ ConfigHandle
+ );
+
+ if ((Length == ETH_LENGTH_OF_ADDRESS) && (Status == NDIS_STATUS_SUCCESS)) {
+
+ ETH_COPY_NETWORK_ADDRESS(
+ NetworkAddress,
+ NetAddress
+ );
+ }
+
+ //
+ // Read Card type
+ //
+
+ NdisReadConfiguration(
+ &Status,
+ &ReturnedValue,
+ ConfigHandle,
+ &AdapterTypeStr,
+ NdisParameterHexInteger
+ );
+
+ if (Status == NDIS_STATUS_SUCCESS) {
+
+ AdapterType = (ReturnedValue->ParameterData.IntegerData);
+ if (AdapterType>4 || AdapterType<0) AdapterType=4;
+
+ }
+
+ if (AdapterType==NIUPS) {
+
+ //
+ // The user seems to think that this is an MCA machine
+ //
+
+ IF_LOUD(DbgPrint("The card is an MCA NIUps, reading POS info\n");)
+
+ NdisReadMcaPosInformation(
+ &Status,
+ ConfigurationHandle,
+ &ChannelNumber,
+ &McaData
+ );
+
+ if (Status != NDIS_STATUS_SUCCESS) {
+ //
+ // Info read failed
+ //
+ IF_LOUD(DbgPrint("Failed to read POS information for card, slot# %d\n",ChannelNumber);)
+ goto Fail00;
+ }
+
+ if (McaData.AdapterId!=0x7012) {
+ //
+ // Not an NIUps adapter in this position
+ //
+ IF_LOUD(DbgPrint("The card found is not an NIUps\n");)
+ goto Fail00;
+ }
+
+ if (!(McaData.PosData1 & 0x01)) {
+ //
+ // Bit 0 is set if the adapter is enabled
+ //
+ IF_LOUD(DbgPrint("The NIUps is not enabled\n");)
+ goto Fail00;
+ }
+
+
+ //
+ // We have found an NIUps in the specified slot
+ //
+
+
+ if (McaData.PosData1 & 0x80) {
+ //
+ // Bit 7 is set so adpater is using IRQ 12
+ //
+ InterruptNumber=12;
+ } else {
+ //
+ // Otherwise it is using IRQ 3
+ //
+ InterruptNumber=3;
+ }
+
+ //
+ // The NIUps has a level triggered interrupt, as compared to
+ // the other two which do not
+ //
+
+ InterruptMode=NdisInterruptLevelSensitive;
+
+
+
+ //
+ // Bit 6 and 5 specify window size
+ //
+
+ tempByte= (McaData.PosData1 & 0x60) >> 5;
+ if (tempByte==3) {
+ //
+ // 3 is and illegal value for memory window size
+ //
+ goto Fail00;
+ }
+ WindowSize=MemoryWindows[tempByte];
+
+ //
+ // Bits 3-0 specify MemoryWindow base addresses
+ //
+
+ MemWindBase=MemoryBases[(McaData.PosData2 & 0x0f)];
+
+ //
+ // Bits 3-0 specify MemoryWindow base addresses
+ //
+
+ IoBaseAddr=PortBases[(McaData.PosData4 & 0x0f)];
+
+
+
+ } else {
+
+ //
+ // No MCA card, read registery for config info
+ //
+
+
+ //
+ // Read I/O Address
+ //
+
+ NdisReadConfiguration(
+ &Status,
+ &ReturnedValue,
+ ConfigHandle,
+ &IOAddressStr,
+ NdisParameterHexInteger
+ );
+
+ if (Status == NDIS_STATUS_SUCCESS) {
+
+ IoBaseAddr = (ReturnedValue->ParameterData.IntegerData);
+
+ }
+
+ //
+ // Confirm value
+ //
+
+ {
+ UCHAR Count;
+
+ static ULONG IoBases[] = { 0x350, 0x358,
+ 0x360, 0x368};
+
+ for (Count = 0 ; Count < 4; Count++) {
+
+ if (IoBaseAddr == IoBases[Count]) {
+
+ break;
+
+ }
+
+ }
+
+ if (Count == 4) {
+ //
+ // Error
+ //
+ goto Fail00;
+ }
+
+ }
+
+ //
+ // Read Memory base window
+ //
+
+ NdisReadConfiguration(
+ &Status,
+ &ReturnedValue,
+ ConfigHandle,
+ &MemWindBaseStr,
+ NdisParameterHexInteger
+ );
+
+ if (Status == NDIS_STATUS_SUCCESS) {
+
+ MemWindBase = (ReturnedValue->ParameterData.IntegerData);
+
+ }
+
+ //
+ // Confirm value
+ //
+
+
+ if (AdapterType==GPCNIU) {
+
+ //
+ // This is an EOTP card that can start on any 32k boundary
+ // from 80000h to e8000h
+ //
+
+ if ( MemWindBase< 0x80000 ||
+ MemWindBase> 0xe8000 ||
+ ((MemWindBase & 0x07fff)!=0)) {
+
+ goto Fail00;
+ }
+
+ } else {
+
+ //
+ // This is an NIUpc card
+ //
+
+ if ( MemWindBase< 0x88000 ||
+ MemWindBase> 0xe8000 ||
+ (((MemWindBase+0x8000) & 0xffff)!=0)) {
+
+ goto Fail00;
+
+ }
+
+ }
+
+
+
+
+ //
+ // Read interrupt number
+ //
+
+ NdisReadConfiguration(
+ &Status,
+ &ReturnedValue,
+ ConfigHandle,
+ &InterruptStr,
+ NdisParameterHexInteger
+ );
+
+ if (Status == NDIS_STATUS_SUCCESS) {
+
+ InterruptNumber = (CCHAR)(ReturnedValue->ParameterData.IntegerData);
+
+ }
+
+
+ //
+ // Confirm value
+ //
+
+ {
+ UCHAR Count;
+
+ static CCHAR InterruptValues[] = { 2, 3, 4, 5, 7, 9, 12 };
+
+ for (Count = 0 ; Count < 7; Count++) {
+
+ if (InterruptNumber == InterruptValues[Count]) {
+
+ break;
+
+ }
+
+ }
+
+ if (Count == 7) {
+ //
+ // Error
+ //
+ goto Fail00;
+ }
+
+ }
+
+ } // non MCA
+
+
+ //
+ // Read MaxMulticastList
+ //
+
+ NdisReadConfiguration(
+ &Status,
+ &ReturnedValue,
+ ConfigHandle,
+ &MaxMulticastListStr,
+ NdisParameterInteger
+ );
+
+ if (Status == NDIS_STATUS_SUCCESS) {
+
+ MaxMulticastList = ReturnedValue->ParameterData.IntegerData;
+
+ }
+
+ //
+ // Read ReceiveBuffSize
+ //
+
+ NdisReadConfiguration(
+ &Status,
+ &ReturnedValue,
+ ConfigHandle,
+ &ReceiveBuffSizeStr,
+ NdisParameterInteger
+ );
+
+ if (Status == NDIS_STATUS_SUCCESS) {
+
+ ReceiveBuffSize = ReturnedValue->ParameterData.IntegerData;
+ if ((ReceiveBuffSize<256) || (ReceiveBuffSize>1514)) {
+ ReceiveBuffSize=256;
+ }
+
+ }
+
+
+
+ //
+ // Read Diagnostics value
+ //
+
+ NdisReadConfiguration(
+ &Status,
+ &ReturnedValue,
+ ConfigHandle,
+ &DiagStr,
+ NdisParameterHexInteger
+ );
+
+ if (Status == NDIS_STATUS_SUCCESS) {
+
+ Diagnostics = (BOOLEAN)(ReturnedValue->ParameterData.IntegerData);
+
+ }
+
+
+ NdisCloseConfiguration(ConfigHandle);
+
+
+
+ //
+ // Set up the parameters.
+ //
+
+ if (MaxMulticastList==3) {
+ IF_LOUD(DbgPrint("Multicast size ==3 Setting to 4 to avoid 82586 bug\n");)
+ MaxMulticastList=4;
+ }
+
+
+ pAdapter->IoPortBaseAddr = (UINT)IoBaseAddr;
+ pAdapter->IrqLevel = InterruptNumber;
+ pAdapter->MemBaseAddr = (UINT)MemWindBase;
+ pAdapter->AdapterType = AdapterType;
+ pAdapter->InterruptMode = InterruptMode;
+ pAdapter->WindowSize = WindowSize;
+ pAdapter->MaxMultiCastTableSize = MaxMulticastList;
+ pAdapter->MaxRequests = MaxRequests;
+ pAdapter->MaxTransmits = DEFAULT_MAXIMUM_TRANSMITS;
+ pAdapter->ReceiveBuffers = DEFAULT_RECEIVE_BUFFERS;
+ pAdapter->ReceiveBufSize = ReceiveBuffSize;
+ pAdapter->Diagnostics = Diagnostics;
+ ETH_COPY_NETWORK_ADDRESS(pAdapter->StationAddress, NetworkAddress);
+
+
+ IF_LOUD( DbgPrint( "Registering adapter type %d\n"
+ "I/O base addr 0x%lx\ninterrupt number %ld\n"
+ "Mem Window base 0x%05lx\nWindowSize %lx\nmax multicast %ld\n"
+ "ReceiveBufferSize %ld\nMaxOpens %d\n", AdapterType,
+ IoBaseAddr, InterruptNumber,MemWindBase,WindowSize,MaxMulticastList,
+ ReceiveBuffSize,MaxOpens );)
+
+
+ return NDIS_STATUS_SUCCESS;
+
+
+Fail00:
+
+ NdisCloseConfiguration(ConfigHandle);
+ return NDIS_STATUS_FAILURE;
+}
diff --git a/private/ntos/ndis/ubnei/debug.h b/private/ntos/ndis/ubnei/debug.h
new file mode 100644
index 000000000..e3a84409b
--- /dev/null
+++ b/private/ntos/ndis/ubnei/debug.h
@@ -0,0 +1,90 @@
+
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ debug.h
+
+Abstract:
+
+ This is the debug header file for the Ungermann Bass Ethernet Controller.
+
+ It contains the various debug definitions and macros used in displaying
+ debugging information on the kernel debugger.
+
+Author:
+
+ Sanjeev Katariya (sanjeevk) 03-05-92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's(dos)
+
+Revision History:
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+--*/
+
+
+#if DBG
+
+#define IF_UBNEIDEBUG(f) if (UbneiDebugFlag & (f))
+extern ULONG UbneiDebugFlag;
+
+extern UCHAR UbneiLog[257];
+extern UCHAR LogPlace;
+
+#define IF_LOG(A) { \
+UbneiLog[LogPlace] = (A); \
+UbneiLog[LogPlace+1] = ' '; \
+UbneiLog[LogPlace+2] = ' '; \
+LogPlace++; \
+}
+
+
+#define UBNEI_DEBUG_LOUD 0x00000001 // debugging info
+#define UBNEI_DEBUG_VERY_LOUD 0x00000002 // excessive debugging info
+#define UBNEI_DEBUG_LOG 0x00000004 // enable UbneiLog
+#define UBNEI_DEBUG_CHECK_DUP_SENDS 0x00000008 // check for duplicate sends
+#define UBNEI_DEBUG_TRACK_PACKET_LENS 0x00000010 // track directed packet lens
+#define UBNEI_DEBUG_WORKAROUND1 0x00000020 // drop DFR/DIS packets
+#define UBNEI_DEBUG_CARD_BAD 0x00000040 // dump data if CARD_BAD
+#define UBNEI_DEBUG_CARD_TESTS 0x00000080 // print reason for failing
+
+#define UBNEI_DEBUG_INIT 0x00000100 // init debugging info
+
+#define UBNEI_DEBUG_SEND 0x00000200 // init debugging info
+#define UBNEI_DEBUG_RCV 0x00000400
+#define UBNEI_DEBUG_REQ 0x00000800
+#define UBNEI_DEBUG_BAD 0x00001000
+
+//
+// Macro for deciding whether to dump lots of debugging information.
+//
+
+#define IF_LOUD(A) IF_UBNEIDEBUG( UBNEI_DEBUG_LOUD ) { A }
+#define IF_VERY_LOUD(A) IF_UBNEIDEBUG( UBNEI_DEBUG_VERY_LOUD ) { A }
+#define IF_INIT_LOUD(A) IF_UBNEIDEBUG( UBNEI_DEBUG_INIT ) { A }
+#define IF_SEND_LOUD(A) IF_UBNEIDEBUG( UBNEI_DEBUG_SEND ) { A }
+#define IF_RCV_LOUD(A) IF_UBNEIDEBUG( UBNEI_DEBUG_RCV ) { A }
+#define IF_REQ_LOUD(A) IF_UBNEIDEBUG( UBNEI_DEBUG_REQ ) { A }
+
+#define IF_BAD_LOUD(A) IF_UBNEIDEBUG( UBNEI_DEBUG_BAD ) { A }
+
+#else
+
+#define IF_LOUD(A)
+#define IF_VERY_LOUD(A)
+#define IF_INIT_LOUD(A)
+#define IF_LOG(A)
+#define IF_SEND_LOUD(A)
+#define IF_RCV_LOUD(A)
+#define IF_REQ_LOUD(A)
+
+#define IF_BAD_LOUD(A)
+
+#endif
diff --git a/private/ntos/ndis/ubnei/init.c b/private/ntos/ndis/ubnei/init.c
new file mode 100644
index 000000000..6d97bf741
--- /dev/null
+++ b/private/ntos/ndis/ubnei/init.c
@@ -0,0 +1,770 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ init.c
+
+Abstract:
+
+ This is the init file for the Ungermann Bass Ethernet Controller.
+ This driver conforms to the NDIS 3.0 interface.
+
+Author:
+
+ Sanjeev Katariya (sanjeevk) 03-05-92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's
+
+Revision History:
+
+ Brian Lieuallen BrianLie 07/21/92
+ Made it work.
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+--*/
+
+
+
+#include <ndis.h>
+#include <efilter.h>
+
+#include "niudata.h"
+#include "debug.h"
+#include "ubhard.h"
+#include "ubsoft.h"
+#include "ubnei.h"
+
+
+#include "map.h"
+
+
+
+#if DBG
+
+UCHAR UbneiLog[257] = {0};
+UCHAR LogPlace = 0;
+
+#endif
+
+
+
+NTSTATUS
+DriverEntry(
+ IN PDRIVER_OBJECT DriverObject,
+ IN PUNICODE_STRING RegistryPath
+ );
+
+
+NDIS_STATUS
+UbneiInitializeAdapter(
+ IN PUBNEI_ADAPTER pAdapter
+ );
+
+
+
+#ifdef ALLOC_PRAGMA
+#pragma NDIS_INIT_FUNCTION(DriverEntry)
+#pragma NDIS_INIT_FUNCTION(UbneiInitialize)
+#pragma NDIS_INIT_FUNCTION(UbneiInitializeAdapter)
+#endif
+
+
+#if DBG
+
+ULONG UbneiDebugFlag;
+
+#endif
+
+
+
+NTSTATUS
+DriverEntry(
+ IN PDRIVER_OBJECT DriverObject,
+ IN PUNICODE_STRING RegistryPath
+ )
+
+
+/*++
+
+Routine Description:
+
+ This is the transfer address of the driver. It initializes all the
+ appropriate variables used and calls NdisInitializeWrapper() and
+ NdisRegisterMac().
+
+
+Arguments:
+
+Return Value:
+
+ Indicates the success or failure of the initialization.
+
+--*/
+
+{
+ NDIS_STATUS InitStatus;
+ NDIS_MINIPORT_CHARACTERISTICS Characteristics;
+ NDIS_HANDLE WrapperHandle;
+
+
+
+#if DBG
+
+ UbneiDebugFlag = 0;
+ UbneiDebugFlag|= UBNEI_DEBUG_LOG;
+ UbneiDebugFlag|= UBNEI_DEBUG_BAD;
+ UbneiDebugFlag|= UBNEI_DEBUG_LOUD;
+ UbneiDebugFlag|= UBNEI_DEBUG_INIT;
+// UbneiDebugFlag|= UBNEI_DEBUG_REQ;
+// UbneiDebugFlag|= UBNEI_DEBUG_RCV;
+// UbneiDebugFlag|= UBNEI_DEBUG_SEND;
+
+
+#endif
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: DriverEntry\n");)
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: size of HIGHNIUDATA is %d\n",sizeof(HIGHNIUDATA));)
+ ASSERT(sizeof(HIGHNIUDATA)==2712);
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: size of LOWNIUDATA is %d\n",sizeof(LOWNIUDATA));)
+ ASSERT(sizeof(LOWNIUDATA)==294);
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: size of NIU_CONTROL_AREA is %d\n",sizeof(NIU_CONTROL_AREA));)
+ ASSERT(sizeof(NIU_CONTROL_AREA)==249);
+
+
+ NdisMInitializeWrapper(
+ &WrapperHandle,
+ DriverObject,
+ RegistryPath,
+ NULL
+ );
+
+
+
+ //
+ // Prepare to call NdisRegisterMac.
+ //
+
+ Characteristics.MajorNdisVersion = UBNEI_NDIS_MAJOR_VERSION;
+ Characteristics.MinorNdisVersion = UBNEI_NDIS_MINOR_VERSION;
+ Characteristics.Reserved = 0;
+ Characteristics.CheckForHangHandler = UbneiCheckForHang;
+ Characteristics.DisableInterruptHandler = NULL; // UbneiDisableInterrupts;
+ Characteristics.EnableInterruptHandler = NULL; // UbneiEnableInterrupts;
+ Characteristics.SendHandler = UbneiMacSend;
+ Characteristics.TransferDataHandler = UbneiTransferData;
+ Characteristics.ResetHandler = UbneiReset;
+ Characteristics.SetInformationHandler = UbneiSetInformation;
+ Characteristics.QueryInformationHandler = UbneiQueryInformation;
+ Characteristics.InitializeHandler = UbneiInitialize;
+ Characteristics.HaltHandler = UbneiHalt;
+ Characteristics.ISRHandler = UbneiIsr;
+ Characteristics.HandleInterruptHandler = UbneiIsrDpc;
+ Characteristics.ReconfigureHandler = UbneiReconfigure;
+
+ InitStatus=NdisMRegisterMiniport(
+ WrapperHandle,
+ &Characteristics,
+ sizeof(Characteristics)
+ );
+
+
+#if DBG
+
+ if (InitStatus != NDIS_STATUS_SUCCESS) {
+
+ IF_LOUD(DbgPrint("UBNEI: NdisMRegisterMiniport failed with code 0x%x\n", InitStatus );)
+
+ } else {
+
+ IF_INIT_LOUD (DbgPrint("UBNEI: NdisMRegisterMiniport succeeded\n" );)
+
+
+ }
+
+#endif
+
+ return InitStatus;
+
+}
+
+
+
+
+
+
+NDIS_STATUS
+UbneiInitialize(
+ OUT PNDIS_STATUS OpenErrorStatus,
+ OUT PUINT SelectedMediumIndex,
+ IN PNDIS_MEDIUM MediumArray,
+ IN UINT MediumArraySize,
+ IN NDIS_HANDLE AdapterHandle,
+ IN NDIS_HANDLE ConfigurationHandle
+ )
+/*++
+Routine Description:
+
+ This is the UBNEI MacAddAdapter routine. The system calls this routine
+ to add support for particular UB adapter. This routine extracts
+ configuration information from the configuration data base and registers
+ the adapter with NDIS.
+
+
+Arguments:
+
+
+Return Value:
+
+ NDIS_STATUS_SUCCESS - Adapter was successfully added.
+ NDIS_STATUS_FAILURE - Adapter was not added
+
+--*/
+{
+
+ PUBNEI_ADAPTER pAdapter;
+ NDIS_STATUS status;
+
+
+
+
+ *OpenErrorStatus=NDIS_STATUS_SUCCESS;
+
+ IF_LOUD (DbgPrint("UBNEI: Initialize\n");)
+
+ //
+ // Scan the media list for our media type (802.3)
+ //
+
+ *SelectedMediumIndex =(UINT) -1;
+
+ while (MediumArraySize > 0) {
+
+ if (MediumArray[--MediumArraySize] == NdisMedium802_3 ) {
+
+ *SelectedMediumIndex = MediumArraySize;
+
+ break;
+ }
+ }
+
+
+ if (*SelectedMediumIndex == -1) {
+
+ return NDIS_STATUS_UNSUPPORTED_MEDIA;
+
+ }
+
+
+
+ status = NdisAllocateMemory(
+ (PVOID *)&pAdapter,
+ sizeof(UBNEI_ADAPTER),
+ 0,
+ HighestAcceptableMax
+ );
+
+ if (status != NDIS_STATUS_SUCCESS) {
+
+ IF_LOUD (DbgPrint("UBNEIAddAdapter():NdisAllocateMemory() failed\n");)
+
+ return NDIS_STATUS_RESOURCES;
+
+ }
+
+ NdisZeroMemory(pAdapter,sizeof(UBNEI_ADAPTER));
+
+ pAdapter->NdisAdapterHandle=AdapterHandle;
+
+
+ //
+ // Read Registery information into Adapter structure
+ //
+
+ if (UbneiReadRegistry(pAdapter,ConfigurationHandle)==NDIS_STATUS_SUCCESS) {
+ //
+ // We got the registry info try to register the adpater
+ //
+
+
+ if (UbneiInitializeAdapter(
+ pAdapter)== NDIS_STATUS_SUCCESS) {
+
+
+ return NDIS_STATUS_SUCCESS;
+
+ }
+
+ } else {
+ IF_LOUD(DbgPrint("Failed to get config info, probably bad Slot number\n");)
+ }
+
+ //
+ // We failed to register the adapter for some reason, so free the
+ // memory for the adapter block and return failure
+
+ NdisFreeMemory(pAdapter,
+ sizeof(UBNEI_ADAPTER),
+ 0);
+
+ return NDIS_STATUS_FAILURE;
+
+}
+
+
+
+
+
+
+NDIS_STATUS
+UbneiInitializeAdapter(
+ IN PUBNEI_ADAPTER pAdapter
+ )
+
+/*++
+
+Routine Description:
+
+ Called when a new adapter should be registered.
+ Initializes the adapter block, and calls NdisRegisterAdapter().
+
+Arguments:
+
+ AdapterName - The name that the system will refer to the adapter by.
+ ConfigurationHandle - Handle passed to MacAddAdapter.
+ Others - Adapter-specific parameters as defined in defaults.h.
+
+Return Value:
+
+ Indicates the success or failure of the registration.
+
+--*/
+
+{
+ NDIS_STATUS Status;
+ NDIS_PHYSICAL_ADDRESS PhysicalAddress;
+
+ NDIS_INTERFACE_TYPE InterfaceType;
+
+ BOOLEAN ConfigError = FALSE;
+ NDIS_ERROR_CODE ConfigErrorCode;
+
+ //
+ // First things first, We only support the following adapter types
+ //
+ // GPCNIU--EOTP
+ // NIUpc --Old long 16-bit card
+ // NIUps --Basically a MicroChannel EOTP
+ //
+
+ if ((pAdapter->AdapterType!=NIUPC) &&
+ (pAdapter->AdapterType!=NIUPS) &&
+ (pAdapter->AdapterType!=GPCNIU)) {
+
+ IF_LOUD(DbgPrint("Sorry, Unsupported UB adapter type %d\n",
+ pAdapter->AdapterType);)
+
+ ConfigError = TRUE;
+ ConfigErrorCode = NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION;
+ goto RegisterAdapter;
+
+ }
+
+
+
+ pAdapter->MaxRequests=DEFAULT_MAXIMUM_REQUESTS;
+
+ pAdapter->MapRegSync.pAdapter=pAdapter;
+
+
+ pAdapter->WindowMask=pAdapter->WindowSize-1;
+ pAdapter->NotWindowMask=~pAdapter->WindowMask;
+
+
+RegisterAdapter:
+
+ //
+ // Set up the AdapterInformation structure; zero it
+ // first in case it is extended later.
+ //
+
+ if (pAdapter->AdapterType==NIUPS) {
+
+ InterfaceType = NdisInterfaceMca;
+
+ } else {
+
+ InterfaceType = NdisInterfaceIsa;
+
+ }
+
+
+ NdisMSetAttributes(
+ pAdapter->NdisAdapterHandle,
+ pAdapter,
+ FALSE,
+ InterfaceType
+ );
+
+ Status=NdisMRegisterIoPortRange(
+ &pAdapter->TranslatedIoBase,
+ pAdapter->NdisAdapterHandle,
+ pAdapter->IoPortBaseAddr,
+ 4
+ );
+
+ if (Status != NDIS_STATUS_SUCCESS) {
+
+ IF_INIT_LOUD (DbgPrint("UBNEI: Failed to register ports\n");)
+
+ NdisWriteErrorLogEntry(
+ pAdapter->NdisAdapterHandle,
+ NDIS_ERROR_CODE_RESOURCE_CONFLICT,
+ 1,
+ (ULONG)pAdapter->MemBaseAddr
+ );
+
+ goto fail1;
+
+ }
+
+
+ pAdapter->MapPort = (PUCHAR)pAdapter->TranslatedIoBase + 0;
+
+ IF_INIT_LOUD (DbgPrint("Map port is 0x%x\n",pAdapter->MapPort);)
+
+ pAdapter->InterruptStatusPort = (PUCHAR)pAdapter->TranslatedIoBase + 1;
+
+ IF_INIT_LOUD (DbgPrint("Interrupt port is 0x%x\n",pAdapter->InterruptStatusPort);)
+
+ pAdapter->SetWindowBasePort = (PUCHAR)pAdapter->TranslatedIoBase + 2;
+
+ IF_INIT_LOUD (DbgPrint("Window base port is 0x%x\n",pAdapter->SetWindowBasePort);)
+
+
+
+
+ //
+ // Map the memory Window into the host address space
+ //
+
+ NdisSetPhysicalAddressHigh(PhysicalAddress, 0);
+ NdisSetPhysicalAddressLow(PhysicalAddress, pAdapter->MemBaseAddr);
+
+
+ Status=NdisMMapIoSpace(
+ &pAdapter->pCardRam,
+ pAdapter->NdisAdapterHandle,
+ PhysicalAddress,
+ pAdapter->WindowSize
+ );
+
+
+ if (Status != NDIS_STATUS_SUCCESS) {
+
+ NdisWriteErrorLogEntry(
+ pAdapter->NdisAdapterHandle,
+ NDIS_ERROR_CODE_RESOURCE_CONFLICT,
+ 1,
+ (ULONG)pAdapter->MemBaseAddr
+ );
+
+ goto fail3;
+
+ }
+
+
+
+ IF_LOUD (DbgPrint("UBNEI: Card mem is at 0x%lx\n",pAdapter->pCardRam);)
+
+ //
+ // Given the memory window and parameters, we now have to setup the
+ // various data units related to ports and memory address in the adapter
+ // block accordingly
+ //
+
+ if (!CardSetup(pAdapter)) {
+
+ //
+ // The NIC and its structures could not be poperly initialized
+ //
+
+ IF_LOUD (DbgPrint("UbneiRegisterAdapter(): CardSetup() Failed\n");)
+
+ Status = NDIS_STATUS_FAILURE;
+
+ NdisWriteErrorLogEntry(
+ pAdapter->NdisAdapterHandle,
+ NDIS_ERROR_CODE_ADAPTER_NOT_FOUND,
+ 0
+ );
+
+ goto fail4;
+ }
+
+
+
+ //
+ // Perform card tests.
+ //
+ if (!CardTest(pAdapter) ) {
+ IF_LOUD ( DbgPrint("CardTest() failed trying again\n");)
+ if (!CardTest(pAdapter) ) {
+
+ IF_LOUD ( DbgPrint("CardTest() failed a second time, game over\n");)
+
+ Status = NDIS_STATUS_FAILURE;
+
+ NdisWriteErrorLogEntry(pAdapter->NdisAdapterHandle,
+ NDIS_ERROR_CODE_ADAPTER_NOT_FOUND,
+ 4,
+ (ULONG)pAdapter->AdapterType,
+ (ULONG)pAdapter->IrqLevel,
+ (ULONG)pAdapter->IoPortBaseAddr,
+ (ULONG)pAdapter->MemBaseAddr
+ );
+
+ goto fail4;
+ }
+ }
+
+
+ //
+ // Copy in permanent address if necessary
+ //
+
+ if (!(pAdapter->StationAddress[0] |
+ pAdapter->StationAddress[1] |
+ pAdapter->StationAddress[2] |
+ pAdapter->StationAddress[3] |
+ pAdapter->StationAddress[4] |
+ pAdapter->StationAddress[5])) {
+
+ ETH_COPY_NETWORK_ADDRESS(pAdapter->StationAddress,
+ pAdapter->PermanentAddress
+ );
+ }
+
+
+
+
+ //
+ // Set up the interrupt handlers.
+ //
+ // It seems that during the reset of an EOTP card it generates and interrupt
+ // on IRQ 5. Note the card has not been told to use IRQ 5, it simply seems to
+ // do this by default.
+ //
+ // If we are initializing IRQ 5 then we will get an interrupt imediatly upon
+ // initializing the IRQ
+ //
+ // If we aren't using 5 then anything that is will get an extra interrupt!!!
+ //
+ // Fine UB engineering
+ //
+ //
+
+ SET_INITWINDOW(pAdapter,INTERRUPT_DISABLED);
+ SET_INITWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ pAdapter->InInit = TRUE;
+
+ Status=NdisMRegisterInterrupt(
+ &pAdapter->NdisInterrupt, // interrupt info str
+ pAdapter->NdisAdapterHandle, // NDIS adapter handle
+ (UINT)pAdapter->IrqLevel, // vector or int number
+ (UINT)pAdapter->IrqLevel, // level or priority
+ TRUE,
+ FALSE, // NOT shared
+ pAdapter->InterruptMode
+ );
+
+
+ if (Status != NDIS_STATUS_SUCCESS) {
+
+ IF_LOUD (DbgPrint("UBNEI: NdisInitializeInterruptFailed\n");)
+ NdisWriteErrorLogEntry(
+ pAdapter->NdisAdapterHandle,
+ NDIS_ERROR_CODE_INTERRUPT_CONNECT,
+ 1,
+ (ULONG)pAdapter->IrqLevel
+ );
+
+
+ goto fail3;
+ }
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: Pause for spurious ISR\n");)
+
+ NdisStallExecution(2000);
+
+
+ //
+ // Here we actaully start the down load code running on the card
+ //
+
+
+ if (!CardStartNIU(pAdapter)) {
+
+ //
+ // The NIU code failed to start.
+ //
+
+ IF_LOUD ( DbgPrint("CardStartNIU() : Failed \n");)
+
+ Status = NDIS_STATUS_FAILURE;
+
+ NdisWriteErrorLogEntry(
+ pAdapter->NdisAdapterHandle,
+ NDIS_ERROR_CODE_HARDWARE_FAILURE,
+ 0
+ );
+
+ goto fail7;
+ }
+
+
+ NIU_OPEN_ADAPTER(pAdapter,DummyDPC);
+
+ NIU_SET_STATION_ADDRESS(pAdapter,DummyDPC,pAdapter->StationAddress);
+
+
+
+ //
+ // Initialization completed successfully.
+ //
+
+ IF_LOUD (DbgPrint("UbneiRegisterAdapter() Succeeded\n");)
+
+ return NDIS_STATUS_SUCCESS;
+
+
+ //
+ // IF WE ARE HERE SOME INITIALIZATION FAILURE OCCURRED
+ //
+
+
+
+ //
+ // Code to unwind what has already been set up when a part of
+ // initialization fails, which is jumped into at various
+ // points based on where the failure occured. Jumping to
+ // a higher-numbered failure point will execute the code
+ // for that block and all lower-numbered ones.
+ //
+
+fail7:
+ NdisMDeregisterInterrupt(&pAdapter->NdisInterrupt);
+
+
+
+fail4:
+ NdisMUnmapIoSpace(
+ pAdapter->NdisAdapterHandle,
+ pAdapter->pCardRam,
+ pAdapter->WindowSize
+ );
+fail3:
+ NdisMDeregisterIoPortRange(
+ pAdapter->NdisAdapterHandle,
+ pAdapter->IoPortBaseAddr,
+ 4,
+ pAdapter->TranslatedIoBase
+ );
+
+fail1:
+
+
+ IF_LOUD (DbgPrint("UbneiRegisterAdapter() Failed\n");)
+//fail0:
+ return Status;
+}
+
+
+
+
+
+
+
+
+
+VOID
+UbneiHalt(
+ IN NDIS_HANDLE MiniportHandle
+ )
+
+{
+
+ PUBNEI_ADAPTER pAdapter=MiniportHandle;
+
+ IF_LOG('q')
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: Halt\n");)
+
+ NdisMDeregisterInterrupt(&pAdapter->NdisInterrupt);
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: Halt: reseting adapter\n");)
+
+ NdisRawWritePortUchar(
+ pAdapter->MapPort,
+ INTERRUPT_DISABLED | RESET_SET
+ );
+
+
+ if ( pAdapter->AdapterType == GPCNIU ) {
+
+ IF_INIT_LOUD( DbgPrint("UBNEI: Disabling the EOTP adapter\n");)
+
+ NdisRawWritePortUchar(
+ pAdapter->InterruptStatusPort,
+ 0x00
+ );
+ }
+
+
+ NdisMUnmapIoSpace(
+ pAdapter->NdisAdapterHandle,
+ pAdapter->pCardRam,
+ pAdapter->WindowSize
+ );
+
+ NdisMDeregisterIoPortRange(
+ pAdapter->NdisAdapterHandle,
+ pAdapter->IoPortBaseAddr,
+ 4,
+ pAdapter->TranslatedIoBase
+ );
+
+ NdisFreeMemory(
+ pAdapter,
+ sizeof(UBNEI_ADAPTER),
+ 0
+ );
+
+ IF_LOG('Q')
+
+}
+
+
+NDIS_STATUS
+UbneiReconfigure(
+ OUT PNDIS_STATUS OpenErrorStatus,
+ IN NDIS_HANDLE MiniportAdapterContext,
+ IN NDIS_HANDLE ConfigurationHandle
+ )
+
+{
+
+ IF_INIT_LOUD(DbgPrint("UBNEI: Reconfigure\n");)
+
+ return NDIS_STATUS_NOT_SUPPORTED;
+
+}
diff --git a/private/ntos/ndis/ubnei/initdata.c b/private/ntos/ndis/ubnei/initdata.c
new file mode 100644
index 000000000..3d3130b1b
--- /dev/null
+++ b/private/ntos/ndis/ubnei/initdata.c
@@ -0,0 +1,223 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ card.c
+
+Abstract:
+
+ This is the mac ndis file for the Ungermann Bass Ethernet Controller.
+ This driver conforms to the NDIS 3.0 interface.
+
+ It is here that the NDIS3.0 functions defined in the MAC characteristic
+ table have been deinfed.
+
+Author:
+
+ Sanjeev Katariya (sanjeevk) 03-05-92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's
+
+Revision History:
+
+ Brian Lieuallen BrianLie 07/21/92
+ Made it work.
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+
+--*/
+
+
+
+// INCLUDES
+#include <ndis.h>
+#include <efilter.h>
+
+#include "niudata.h"
+#include "debug.h"
+
+#include "ubhard.h"
+#include "ubsoft.h"
+#include "ubnei.h"
+
+#include "map.h"
+
+#ifdef NDIS_NT
+#ifdef ALLOC_DATA_PRAGMA
+
+#pragma data_seg("INIT")
+
+#endif
+#endif
+
+
+
+
+NIUDETAILS NiuDetails[6]={
+// PCNIU--Not supported
+ {0},
+
+// Cost_Reduced-PCNIU-- Not Supported
+ {0},
+
+// NIUpc(long 16-bit card)
+ { { 0x02, 0x12, 0x06, 0x16,
+ 0x0A, 0x1A, 0x0E, 0x1E
+ },
+
+ ATLANTA,
+ NIUPC_MINIMUM_WINDOW_SIZE,
+ NIUPC_OPERATIONAL_CS,
+ NIUPC_PRIMARY_DS,
+ NIUPC_TX_BUFFER_SEGS,
+ NIUPC_HIGHEST_RAM_SEGS,
+ NIUPC_SCSP_SEGS,
+
+ NIUPC_POD_STATUS_ADDR,
+
+ NIUPC_HOST_INTR_PORT,
+ NIUPC_82586_CA_PORT,
+ NIUPC_82586_RESET_PORT,
+ NIUPC_ADAPTER_CTRL_PORT,
+
+ NIUPC_LEDOFF_12V_DOPARCHK,
+ NIUPC_LEDON_12V_DOPARCHK,
+
+ NIUPC_IRQSEL_LEDPORT,
+ NIUPC_DEADMAN_TIMERPORT,
+
+ { NIUPC_CLI_OFFSET,
+ NIUPC_MAP_OFFSET,
+ NIUPC_INTR_STATUS_OFFSET,
+ NIUPC_SETWINBASE_OFFSET
+ },
+
+ NIUPC_ADAPTER_FLAGS,
+ NIUPC_ADAPTER_CODE
+ },
+
+// NIUps (MCA EOTP)
+ { { 0x02, 0x06, 0x0A, 0x0E,
+ 0x12, 0x16, 0x1A, 0x1E,
+ 0x22, 0x26, 0x2A, 0x2E,
+ 0x32, 0x36, 0x3A, 0x3E,
+ 0x42, 0x46, 0x4A, 0x4E,
+ 0x52, 0x56, 0x5A, 0x5E,
+ 0x62, 0x66, 0x6A, 0x6E,
+ 0x72, 0x76, 0x7A, 0x7E
+ },
+
+ CHAMELEON,
+ GPCNIU_MINIMUM_WINDOW_SIZE,
+ GPCNIU_OPERATIONAL_CS,
+ GPCNIU_PRIMARY_DS,
+ GPCNIU_TX_BUFFER_SEGS,
+ GPCNIU_HIGHEST_RAM_SEGS,
+ GPCNIU_SCSP_SEGS,
+
+ GPCNIU_POD_STATUS_ADDR,
+
+ GPCNIU_HOST_INTR_PORT,
+ GPCNIU_82586_CA_PORT,
+ GPCNIU_82586_RESET_PORT,
+ GPCNIU_ADAPTER_CTRL_PORT,
+
+ GPCNIU_LEDOFF_12V_DOPARCHK,
+ GPCNIU_LEDON_12V_DOPARCHK,
+
+ GPCNIU_IRQSEL_LEDPORT,
+ GPCNIU_DEADMAN_TIMERPORT,
+
+ { GPCNIU_CLI_OFFSET,
+ GPCNIU_MAP_OFFSET,
+ GPCNIU_INTR_STATUS_OFFSET,
+ GPCNIU_SETWINBASE_OFFSET
+ },
+
+ GPCNIU_ADAPTER_FLAGS,
+ NIUPS_ADAPTER_CODE
+ },
+
+
+// GPCNIU (EOTP)
+ { { 0x02, 0x06, 0x0A, 0x0E,
+ 0x12, 0x16, 0x1A, 0x1E,
+ 0x22, 0x26, 0x2A, 0x2E,
+ 0x32, 0x36, 0x3A, 0x3E,
+ 0x42, 0x46, 0x4A, 0x4E,
+ 0x52, 0x56, 0x5A, 0x5E,
+ 0x62, 0x66, 0x6A, 0x6E,
+ 0x72, 0x76, 0x7A, 0x7E
+ },
+
+ CHAMELEON,
+ GPCNIU_MINIMUM_WINDOW_SIZE,
+ GPCNIU_OPERATIONAL_CS,
+ GPCNIU_PRIMARY_DS,
+ GPCNIU_TX_BUFFER_SEGS,
+ GPCNIU_HIGHEST_RAM_SEGS,
+ GPCNIU_SCSP_SEGS,
+
+ GPCNIU_POD_STATUS_ADDR,
+
+ GPCNIU_HOST_INTR_PORT,
+ GPCNIU_82586_CA_PORT,
+ GPCNIU_82586_RESET_PORT,
+ GPCNIU_ADAPTER_CTRL_PORT,
+
+ GPCNIU_LEDOFF_12V_DOPARCHK,
+ GPCNIU_LEDON_12V_DOPARCHK,
+
+ GPCNIU_IRQSEL_LEDPORT,
+ GPCNIU_DEADMAN_TIMERPORT,
+
+ { GPCNIU_CLI_OFFSET,
+ GPCNIU_MAP_OFFSET,
+ GPCNIU_INTR_STATUS_OFFSET,
+ GPCNIU_SETWINBASE_OFFSET
+ },
+
+ GPCNIU_ADAPTER_FLAGS,
+ GPCNIU_ADAPTER_CODE
+ },
+
+// PCNIUex -- Not Supported
+ {0},
+
+ };
+
+
+UCHAR GPNIU_IRQ_Selections[13]={0,0,0x10,0x20,0x30,0x40,0,0x50,0,0x10,0,0,0x60};
+
+
+
+
+ULONG MemoryWindows[4]={0x08000,0x10000,0x04000,0x0};
+
+ULONG MemoryBases[16]={0x0c0000,0x0c4000,0x0c8000,0x0cc000,
+ 0x0d0000,0x0d4000,0x0d8000,0x0dc000,
+ 0xe28000,0x0c4000,0x0c8000,0x0cc000,
+ 0x0d0000,0x0d4000,0x0d8000,0x0dc000};
+
+USHORT PortBases[16]={ 0x350,0x350,0x358,0x358,
+ 0x360,0x360,0x368,0x368,
+ 0x368,0x368,0x368,0x368,
+ 0x368,0x368,0x368,0x368};
+
+
+
+
+
+#ifdef NDIS_NT
+#ifdef ALLOC_DATA_PRAGMA
+
+#pragma data_seg()
+
+#endif
+#endif
diff --git a/private/ntos/ndis/ubnei/interrup.c b/private/ntos/ndis/ubnei/interrup.c
new file mode 100644
index 000000000..392eed154
--- /dev/null
+++ b/private/ntos/ndis/ubnei/interrup.c
@@ -0,0 +1,337 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ macndis.c
+
+Abstract:
+
+ This is the mac ndis file for the Ungermann Bass Ethernet Controller.
+ This driver conforms to the NDIS 3.0 interface.
+
+ It is here that the NDIS3.0 functions defined in the MAC characteristic
+ table have been deinfed.
+
+Author:
+
+ Sanjeev Katariya (sanjeevk) 03-05-92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's(dos)
+
+Revision History:
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+--*/
+
+
+
+
+#include <ndis.h>
+#include <efilter.h>
+
+#include "niudata.h"
+#include "debug.h"
+#include "ubhard.h"
+#include "ubsoft.h"
+#include "ubnei.h"
+
+#include "map.h"
+
+
+// GLOBAL VARIABLES
+
+
+
+
+VOID
+UbneiIsr(
+ OUT PBOOLEAN InterruptRecognized,
+ OUT PBOOLEAN QueueDpc,
+ IN NDIS_HANDLE Context
+ )
+
+
+/*++
+
+Routine Description:
+ This is the interrupt service routine for the driver.
+ All it does is disable interrupts from the NIU code and dismiss the
+ interrupt from the card. Interrupts will remain disabled until the
+ DPC runs.
+
+ Any time that interrupts are enabled, the receive window will be
+ the one that is mapped in. This is done beacuse in order to dismiss
+ the interrupt from the card you must write a value to the map port
+ with zero bit clear and then set.
+
+
+Arguments:
+
+ ServiceContext - pointer to the adapter object
+
+Return Value:
+
+ TRUE, if the DPC is to be executed, otherwise FALSE.
+
+--*/
+
+{
+ PUBNEI_ADAPTER pAdapter = ((PUBNEI_ADAPTER)Context);
+ PLOWNIUDATA pRcvDWindow = (PLOWNIUDATA) pAdapter->pCardRam;
+
+ *InterruptRecognized=TRUE;
+ *QueueDpc=TRUE;
+
+ IF_VERY_LOUD(DbgPrint("Ubnei: ISR\n");)
+
+
+ IF_LOG('i');
+
+ if (pAdapter->InInit) {
+
+ IF_LOUD(DbgPrint("UBNEI: Isr durring init\n");)
+
+ pAdapter->uInterruptCount++;
+
+ SET_DATAWINDOW(pAdapter,INTERRUPT_DISABLED);
+ SET_DATAWINDOW(pAdapter,INTERRUPT_ENABLED);
+ SET_DATAWINDOW(pAdapter,INTERRUPT_DISABLED);
+
+ IF_LOG('|');
+
+ *QueueDpc=FALSE;
+
+ return;
+ }
+
+
+ if (pAdapter->WaitingForDPC) {
+ //
+ // Spurious interrupt???
+ //
+
+ IF_LOG('!');
+
+ IF_LOUD (DbgPrint("UBNEI: Isr ran while in DPC\n");)
+
+ *InterruptRecognized=FALSE;
+
+ *QueueDpc=FALSE;
+
+ return;
+ }
+
+ //
+ // Dismiss the interrupt from the card.
+ // To do this we need to write a zero to bit 1 of the
+ // the map port followed by a one to bit 1
+ //
+ NdisRawWritePortUchar(
+ pAdapter->MapPort,
+ pAdapter->MapRegSync.CurrentMapRegister & ~(INTERRUPT_ENABLED | RESET_SET)
+ );
+
+
+ NdisRawWritePortUchar(
+ pAdapter->MapPort,
+ pAdapter->MapRegSync.CurrentMapRegister | INTERRUPT_ENABLED
+ );
+
+
+ pAdapter->WaitingForDPC=TRUE;
+
+
+ IF_LOG('I');
+
+ return;
+
+}
+
+
+
+
+
+VOID
+UbneiIsrDpc(
+ IN NDIS_HANDLE Context
+ )
+
+/*++
+
+Routine Description:
+ This is the Interrupt DPC routine. This routine is the workhorse of
+ this driver. The only code that changes the map register is called
+ by this rountine. While this routine is running interrupts are disabled
+ from the card. This code enables them on exit.
+
+Arguments:
+
+
+Return Value:
+
+
+--*/
+
+{
+ PUBNEI_ADAPTER pAdapter = ((PUBNEI_ADAPTER)Context);
+ PLOWNIUDATA pRcvDWindow = (PLOWNIUDATA) pAdapter->pCardRam;
+
+ ASSERT_RECEIVE_WINDOW( pAdapter);
+
+ IF_VERY_LOUD (DbgPrint("UBNEI: DPC called\n");)
+
+ IF_LOG('p');
+
+ //
+ // The down load code will not generate interrupts if the
+ // interrupt disable flag is set. We also leave the InterruptActive
+ // set which also prevents additional interrupts.
+ //
+//
+// Since the Interreupt active flag is set, there is really no reason
+// to set the interrupt disabled flag to. One fewer access across the isa bus
+//
+// UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pRcvDWindow->InterruptDisabled), 0xff);
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pRcvDWindow->WorkForHost), 0x0);
+
+
+
+ //
+ // This rountine will indicate all receives that are in the receive
+ // buffers on the card. It does not return until it has indicated all
+ // of the receives.
+ //
+ CheckForReceives(pAdapter);
+
+ //
+ // If we filled up all the cards send buffer, then we would have queue
+ // the packet and ask the card to generate an interrupt when there was
+ // room. If the queue isn't empty, try to send some packet to the card.
+ //
+
+ if (pAdapter->WaitingForXmitInterrupt) {
+
+ pAdapter->WaitingForXmitInterrupt=FALSE;
+
+ IF_LOUD(DbgPrint("UBNEI: Xmt interrupt\n");)
+
+ IF_LOG('O');
+
+ NdisMSendResourcesAvailable(pAdapter->NdisAdapterHandle);
+
+ }
+
+
+ //
+ // This routine handles completeing NIU requests
+ //
+ if (pAdapter->NIU_Request_Tail!=pAdapter->NIU_Next_Request) {
+ //
+ // We have an outstanding request see if it has completed
+ //
+ NIU_General_Req_Result_Hand(pAdapter);
+
+ }
+
+
+ //
+ // Re-enable interrupts from the NIU code.
+ //
+
+ pAdapter->DpcHasRun=TRUE;
+
+ pAdapter->WaitingForDPC=FALSE;
+
+ ASSERT_RECEIVE_WINDOW( pAdapter);
+
+ //
+ // Allow the card to generate an interrupt to us
+ //
+ // The download code will not interrupt us if either of these
+ // memory locations are non zero.
+ //
+ // Before the down load code generates an interrupt to us
+ // it will set the InterruptActive flag. This will prevent it
+ // from generating any more until we clear it.
+ //
+ //
+
+//
+// Combine these two writes to the shared ram to one word write
+//
+// UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pRcvDWindow->InterruptActive), 0x0);
+//
+// UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pRcvDWindow->InterruptDisabled), 0x0);
+//
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM((PUSHORT)&(pRcvDWindow->InterruptDisabled), 0x0);
+
+
+
+ IF_LOG('P');
+
+// ASSERT_INTERRUPT_ENABLED(pAdapter);
+
+ return;
+}
+
+
+BOOLEAN
+UbneiSetInitInterruptSync(
+ PVOID Context
+ )
+/*++
+
+Routine Description:
+ This routine is called by the init code to set the flag to
+ cause the interrupt to handled by the init code.
+
+Arguments:
+
+
+Return Value:
+
+
+--*/
+
+{
+ PUBNEI_ADAPTER pAdapter = ((PUBNEI_ADAPTER)Context);
+
+ pAdapter->InInit=TRUE;
+ return TRUE;
+}
+
+
+
+BOOLEAN
+UbneiSetNormalInterruptSync(
+ PVOID Context
+ )
+/*++
+
+Routine Description:
+ This routine is called by the init code to set the flag to
+ cause the interrupt to handled by the normal runtime code.
+
+
+Arguments:
+
+
+Return Value:
+
+
+--*/
+
+{
+ PUBNEI_ADAPTER pAdapter = ((PUBNEI_ADAPTER)Context);
+
+ pAdapter->InInit=FALSE;
+ return TRUE;
+}
diff --git a/private/ntos/ndis/ubnei/keywords.h b/private/ntos/ndis/ubnei/keywords.h
new file mode 100644
index 000000000..963325196
--- /dev/null
+++ b/private/ntos/ndis/ubnei/keywords.h
@@ -0,0 +1,57 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ keywords.h
+
+Abstract:
+
+ Contains all Ndis2 and Ndis3 mac-specific keywords.
+
+Author:
+
+ Bob Noradki
+
+Environment:
+
+ This driver is expected to work in DOS, OS2 and NT at the equivalent
+ of kernal mode.
+
+ Architecturally, there is an assumption in this driver that we are
+ on a little endian machine.
+
+Notes:
+
+ optional-notes
+
+Revision History:
+
+
+
+--*/
+#ifndef NDIS2
+#define NDIS2 0
+#endif
+
+#if NDIS2
+
+#define IOADDRESS NDIS_STRING_CONST("IO_Port")
+#define INTERRUPT NDIS_STRING_CONST("IRQ_Level")
+#define MAX_MULTICAST_LIST NDIS_STRING_CONST("MaxMulticast")
+#define CARDTYPE NDIS_STRING_CONST("AdapterType")
+#define MEMMAPPEDBASE NDIS_STRING_CONST("MemoryWindow")
+#define RCVBUFSIZE NDIS_STRING_CONST("ReceiveBufSize")
+
+#else // NDIS3
+
+
+#define CARDTYPE NDIS_STRING_CONST("CardType")
+#define MEMMAPPEDBASE NDIS_STRING_CONST("MemoryMappedBaseAddress")
+#define IOADDRESS NDIS_STRING_CONST("IoBaseAddress")
+#define INTERRUPT NDIS_STRING_CONST("InterruptNumber")
+#define MAX_MULTICAST_LIST NDIS_STRING_CONST("MaximumMulticastList")
+#define RCVBUFSIZE NDIS_STRING_CONST("ReceiveBufferSize")
+
+#endif
diff --git a/private/ntos/ndis/ubnei/makefile b/private/ntos/ndis/ubnei/makefile
new file mode 100644
index 000000000..677d610db
--- /dev/null
+++ b/private/ntos/ndis/ubnei/makefile
@@ -0,0 +1,6 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
+# file to this component. This file merely indirects to the real make file
+# that is shared by all the components of NT
+#
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/ntos/ndis/ubnei/makefile.inc b/private/ntos/ndis/ubnei/makefile.inc
new file mode 100644
index 000000000..8c67f2e22
--- /dev/null
+++ b/private/ntos/ndis/ubnei/makefile.inc
@@ -0,0 +1,5 @@
+ubnei.bin: $(TARGETEXEFILES)
+ chmode -r ubnei.bin
+ binplace ubnei.bin
+ touch ubnei.bin
+ chmode +r ubnei.bin
diff --git a/private/ntos/ndis/ubnei/map.c b/private/ntos/ndis/ubnei/map.c
new file mode 100644
index 000000000..e0901061a
--- /dev/null
+++ b/private/ntos/ndis/ubnei/map.c
@@ -0,0 +1,256 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ init.c
+
+Abstract:
+
+ This is the init file for the Ungermann Bass Ethernet Controller.
+ This driver conforms to the NDIS 3.0 interface.
+
+Author:
+
+ Brian Lieuallen BrianLie 11/21/93
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's
+
+Revision History:
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+--*/
+
+#include <ndis.h>
+//#include <efilter.h>
+
+#include "niudata.h"
+#include "debug.h"
+#include "ubhard.h"
+#include "ubsoft.h"
+#include "ubnei.h"
+
+#include "map.h"
+
+
+VOID
+UbneiMapRegisterChangeSync(
+ PSYNC_CONTEXT Context
+ )
+
+{
+ PUBNEI_ADAPTER pAdapter=(PUBNEI_ADAPTER) Context->pAdapter;
+
+#if DBG
+
+ UCHAR MapByte;
+
+ if (pAdapter->AdapterType==GPCNIU) {
+
+ NdisRawReadPortUchar(
+ pAdapter->MapPort,
+ &MapByte
+ );
+
+
+ if ((MapByte & 0xfc) != Context->CurrentMapRegister & 0xfc) {
+ IF_BAD_LOUD(
+ DbgPrint("UBNEI: BOOM! Wrong window mapped is %02x should be %02x\n",MapByte,Context->CurrentMapRegister);
+ DbgBreakPoint();
+ )
+ }
+ }
+
+#endif
+
+ NdisRawWritePortUchar(
+ pAdapter->MapPort,
+ Context->NewMapRegister
+ );
+
+
+ Context->CurrentMapRegister=Context->NewMapRegister;
+
+ return;
+}
+
+
+
+
+
+#if DBG
+//
+// We declare these macros as functions to simplify debugging with
+// the kd
+
+
+
+VOID
+ASSERT_INTERRUPT_ENABLED(
+ PUBNEI_ADAPTER pAdapter
+ )
+
+{
+
+ UCHAR MapByte;
+
+ if (pAdapter->AdapterType==GPCNIU) {
+
+ NdisRawReadPortUchar(
+ (ULONG)pAdapter->MapPort,
+ &MapByte
+ );
+
+ if ((MapByte & INTERRUPT_ENABLED) == 0) {
+
+ IF_LOUD(
+ DbgPrint("Ubnei: Interrupt not enabled value=%02x\n",MapByte);
+ DbgBreakPoint();
+ )
+
+ }
+
+ }
+ return;
+
+}
+
+
+
+VOID ASSERT_RECEIVE_WINDOW(PUBNEI_ADAPTER pNewAdapt)
+ {
+ UCHAR Map_Byte;
+ if (pNewAdapt->AdapterType==GPCNIU) {
+
+ NdisRawReadPortUchar(
+ (ULONG)pNewAdapt->MapPort,
+ &Map_Byte
+ );
+ if ((Map_Byte & ~INTERRUPT_ENABLED)!=(pNewAdapt->ReceiveDataWindow_Page)) {
+ IF_BAD_LOUD(
+ DbgPrint("UBNEI: Receive window not mapped in %02x\n",Map_Byte);
+ DbgBreakPoint();
+ )
+ }
+ }
+ return;
+ }
+
+
+VOID SET_RECDWINDOW(PUBNEI_ADAPTER pAdapter,UCHAR intflag)
+ {
+ IF_VERY_LOUD (DbgPrint( "-->Set to recd window\n" );)
+ IF_LOG('R');
+
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->ReceiveDataWindow_Page | ((UCHAR)intflag));
+
+ UbneiMapRegisterChangeSync(&pAdapter->MapRegSync);
+ }
+
+VOID SET_INITWINDOW(PUBNEI_ADAPTER pAdapter,UCHAR intflag)
+ {
+ IF_VERY_LOUD (DbgPrint( "-->Set to init window\n" );)
+ IF_LOG('N');
+
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->InitWindow_Page | ((UCHAR)intflag));
+
+ UbneiMapRegisterChangeSync(&pAdapter->MapRegSync);
+
+ }
+
+VOID SET_DATAWINDOW(PUBNEI_ADAPTER pAdapter,UCHAR intflag)
+ {
+ IF_VERY_LOUD (DbgPrint( "-->Set to data window\n" );)
+ IF_LOG('D');
+
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->DataWindow_Page | ((UCHAR)intflag));
+
+ UbneiMapRegisterChangeSync(&pAdapter->MapRegSync);
+
+ }
+
+VOID SET_CODEWINDOW(PUBNEI_ADAPTER pAdapter,UCHAR intflag)
+ {
+ IF_VERY_LOUD (DbgPrint( "-->Set to code window\n" );)
+ IF_LOG('C');
+
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->CodeWindow_Page | ((UCHAR)intflag));
+
+ UbneiMapRegisterChangeSync(&pAdapter->MapRegSync);
+
+ }
+
+
+
+
+VOID SET_RECDWINDOW_SYNC(PUBNEI_ADAPTER pAdapter,UCHAR intflag)
+ {
+ IF_VERY_LOUD (DbgPrint( "-->Set to recd window\n" );)
+ IF_LOG('R');
+
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->ReceiveDataWindow_Page | ((UCHAR)intflag));
+
+ NdisMSynchronizeWithInterrupt(
+ &pAdapter->NdisInterrupt,
+ UbneiMapRegisterChangeSync,
+ &pAdapter->MapRegSync
+ );
+
+ }
+
+VOID SET_INITWINDOW_SYNC(PUBNEI_ADAPTER pAdapter,UCHAR intflag)
+ {
+ IF_VERY_LOUD (DbgPrint( "-->Set to init window\n" );)
+ IF_LOG('N');
+
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->InitWindow_Page | ((UCHAR)intflag));
+
+ NdisMSynchronizeWithInterrupt(
+ &pAdapter->NdisInterrupt,
+ UbneiMapRegisterChangeSync,
+ &pAdapter->MapRegSync
+ );
+
+
+ }
+
+VOID SET_DATAWINDOW_SYNC(PUBNEI_ADAPTER pAdapter,UCHAR intflag)
+ {
+ IF_VERY_LOUD (DbgPrint( "-->Set to data window\n" );)
+ IF_LOG('D');
+
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->DataWindow_Page | ((UCHAR)intflag));
+
+ NdisMSynchronizeWithInterrupt(
+ &pAdapter->NdisInterrupt,
+ UbneiMapRegisterChangeSync,
+ &pAdapter->MapRegSync
+ );
+
+
+ }
+
+VOID SET_CODEWINDOW_SYNC(PUBNEI_ADAPTER pAdapter,UCHAR intflag)
+ {
+ IF_VERY_LOUD (DbgPrint( "-->Set to code window\n" );)
+ IF_LOG('C');
+
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->CodeWindow_Page | ((UCHAR)intflag));
+
+ NdisMSynchronizeWithInterrupt(
+ &pAdapter->NdisInterrupt,
+ UbneiMapRegisterChangeSync,
+ &pAdapter->MapRegSync
+ );
+
+
+ }
+
+
+#endif
diff --git a/private/ntos/ndis/ubnei/map.h b/private/ntos/ndis/ubnei/map.h
new file mode 100644
index 000000000..171fd5dec
--- /dev/null
+++ b/private/ntos/ndis/ubnei/map.h
@@ -0,0 +1,164 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ init.c
+
+Abstract:
+
+ This is the init file for the Ungermann Bass Ethernet Controller.
+ This driver conforms to the NDIS 3.0 interface.
+
+Author:
+
+ Brian Lieuallen BrianLie 11/21/93
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's
+
+Revision History:
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+--*/
+
+
+
+#if DBG
+
+// declared in init.c
+
+VOID
+ASSERT_INTERRUPT_ENABLED(
+ PUBNEI_ADAPTER pAdapter
+ );
+
+
+
+VOID ASSERT_RECEIVE_WINDOW(PUBNEI_ADAPTER pNewAdapt);
+
+VOID SET_RECDWINDOW(PUBNEI_ADAPTER pNewAdapt,UCHAR intflag);
+
+VOID SET_INITWINDOW(PUBNEI_ADAPTER pNewAdapt,UCHAR intflag);
+
+VOID SET_DATAWINDOW(PUBNEI_ADAPTER pNewAdapt,UCHAR intflag);
+
+VOID SET_CODEWINDOW(PUBNEI_ADAPTER pNewAdapt,UCHAR intflag);
+
+VOID SET_RECDWINDOW_SYNC(PUBNEI_ADAPTER pNewAdapt,UCHAR intflag);
+
+VOID SET_INITWINDOW_SYNC(PUBNEI_ADAPTER pNewAdapt,UCHAR intflag);
+
+VOID SET_DATAWINDOW_SYNC(PUBNEI_ADAPTER pNewAdapt,UCHAR intflag);
+
+VOID SET_CODEWINDOW_SYNC(PUBNEI_ADAPTER pNewAdapt,UCHAR intflag);
+
+
+#else
+
+#define ASSERT_INTERRUPT_ENABLED(pAdapter)
+
+#define ASSERT_RECEIVE_WINDOW(pNewAdapt)
+
+
+#define SET_RECDWINDOW(pAdapter,intflag) { \
+ \
+ pAdapter->MapRegSync.CurrentMapRegister=pAdapter->ReceiveDataWindow_Page | (intflag);\
+ \
+ NdisRawWritePortUchar ( \
+ (ULONG)pAdapter->MapPort, \
+ pAdapter->MapRegSync.CurrentMapRegister \
+ ); \
+ }
+
+#define SET_INITWINDOW(pAdapter,intflag) { \
+ \
+ pAdapter->MapRegSync.CurrentMapRegister=(pAdapter->InitWindow_Page | ((UCHAR)(intflag))); \
+ \
+ NdisRawWritePortUchar ( \
+ (ULONG)pAdapter->MapPort, \
+ pAdapter->MapRegSync.CurrentMapRegister \
+ ); \
+ }
+
+
+#define SET_DATAWINDOW(pAdapter,intflag) { \
+ \
+ pAdapter->MapRegSync.CurrentMapRegister=pAdapter->DataWindow_Page | (intflag);\
+ \
+ NdisRawWritePortUchar ( \
+ (ULONG)pAdapter->MapPort, \
+ pAdapter->MapRegSync.CurrentMapRegister \
+ ); \
+ }
+
+
+#define SET_CODEWINDOW(pAdapter,intflag) { \
+ \
+ pAdapter->MapRegSync.CurrentMapRegister=(pAdapter->CodeWindow_Page | ((UCHAR)(intflag))); \
+ \
+ NdisRawWritePortUchar ( \
+ (ULONG)pAdapter->MapPort, \
+ pAdapter->MapRegSync.CurrentMapRegister \
+ ); \
+ }
+
+
+
+#define SET_RECDWINDOW_SYNC(pAdapter,intflag) { \
+ \
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->ReceiveDataWindow_Page | ((UCHAR)intflag)); \
+ \
+ NdisMSynchronizeWithInterrupt( \
+ &pAdapter->NdisInterrupt, \
+ UbneiMapRegisterChangeSync, \
+ &pAdapter->MapRegSync \
+ ); \
+ \
+ }
+
+#define SET_INITWINDOW_SYNC(pAdapter, intflag) { \
+ \
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->InitWindow_Page | ((UCHAR)intflag)); \
+ \
+ NdisMSynchronizeWithInterrupt( \
+ &pAdapter->NdisInterrupt, \
+ UbneiMapRegisterChangeSync, \
+ &pAdapter->MapRegSync \
+ ); \
+ \
+ }
+
+#define SET_DATAWINDOW_SYNC(pAdapter, intflag) { \
+ \
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->DataWindow_Page | ((UCHAR)intflag)); \
+ \
+ NdisMSynchronizeWithInterrupt( \
+ &pAdapter->NdisInterrupt, \
+ UbneiMapRegisterChangeSync, \
+ &pAdapter->MapRegSync \
+ ); \
+ \
+ }
+
+#define SET_CODEWINDOW_SYNC( pAdapter, intflag) { \
+ \
+ pAdapter->MapRegSync.NewMapRegister=(pAdapter->CodeWindow_Page | ((UCHAR)intflag)); \
+ \
+ NdisMSynchronizeWithInterrupt( \
+ &pAdapter->NdisInterrupt, \
+ UbneiMapRegisterChangeSync, \
+ &pAdapter->MapRegSync \
+ ); \
+ \
+ }
+
+
+
+
+#endif
diff --git a/private/ntos/ndis/ubnei/niudata.h b/private/ntos/ndis/ubnei/niudata.h
new file mode 100644
index 000000000..1721bbbcf
--- /dev/null
+++ b/private/ntos/ndis/ubnei/niudata.h
@@ -0,0 +1,562 @@
+
+#include "packon.h"
+
+
+typedef struct _X86ADDRESS {
+ union {
+ ULONG dword;
+ struct {
+ USHORT Offset;
+ USHORT Segment;
+ } SegOff;
+ } u;
+} X86ADDRESS;
+
+typedef struct tagServiceStatus {
+ USHORT SST_TableSize;
+ ULONG SST_LastDiagnosticsTime;
+ ULONG SST_Mac_Status;
+ USHORT SST_CurrentPacketFilter;
+ ULONG SST_MediaSpecificStatisticsPtr;
+ ULONG SST_LastClearStatisticsTime;
+
+
+
+ ULONG SST_TotalFramesReceived ;
+ ULONG SST_FramesWithCRCError ;
+ ULONG SST_TotalBytesReceived ;
+ ULONG SST_FramesDiscarded_NoBufferSpace ;
+ ULONG SST_MulticastFramesReceived ;
+ ULONG SST_BroadcastFramesReceived ;
+ ULONG SST_FramesReceivedWithErrors ;
+ ULONG SST_FramesExceedingMaximumSize ;
+ ULONG SST_FramesSmallerThanMinimumSize ;
+ ULONG SST_MulticastBytesReceived ;
+ ULONG SST_BroadcastBytesReceived ;
+ ULONG SST_FramesDiscarded_HardwareError ;
+ ULONG SST_TotalFramesTransmitted ;
+ ULONG SST_TotalBytesTransmitted ;
+ ULONG SST_MulticastFramesTransmitted ;
+ ULONG SST_BroadcastFramesTransmitted ;
+ ULONG SST_BroadcastBytesTransmitted ;
+ ULONG SST_MulticastBytesTransmitted ;
+ ULONG SST_FramesNotTransmitted_Timeout ;
+ ULONG SST_FramesNotTransmitted_HardwareError ;
+ ULONG res[3];
+ } ServiceStatus;
+
+typedef struct tagMediaStatistics {
+ USHORT MST_TableSize ;
+ USHORT MST_StructureVersionLevel ;
+ ULONG MST_FramesWithAlignmentError ;
+ ULONG MST_ReceiveErrorFailureMask ;
+ ULONG MST_FramesWithOverrunError ;
+ ULONG MST_FramesTransmittedAfterAnyCollisions;
+ ULONG MST_FramesTransmittedAfterDeferring ;
+ ULONG MST_FramesNotTransmitted_MaxCollisions ;
+ ULONG MST_TotalCollisions ;
+ ULONG MST_LateCollisions ;
+ ULONG MST_FramesTransmittedAfterJustOneCollision ;
+ ULONG MST_FramesTransmittedAfterMultipleCollisions ;
+ ULONG MST_FramesTransmitted_CD_Heartbeat ;
+ ULONG MST_JabberErrors ;
+ ULONG MST_CarrierSenseLostDuringTransmission ;
+ ULONG MST_TransmitErrorFailureMask ;
+ ULONG MST_NumberOfUnderruns ;
+ } MediaStatistics;
+
+typedef volatile struct tagNIUData {
+ char szSST[16];
+ ServiceStatus sst;
+
+ char szMST[16];
+ MediaStatistics mst;
+
+// d0-d7
+ char szRFD[6];
+ USHORT RFD_Start;
+
+// d8-df
+ char szRBD[6];
+ USHORT RBD_Start;
+
+// e0-ef
+
+ UCHAR InterruptDisabled ;
+ UCHAR InterruptActive ;
+ UCHAR WorkForHost ;
+ UCHAR HostWantsInterrupt ;
+ USHORT HostQueuedTransmits ;
+ USHORT RU_Start_Count ;
+ USHORT res ;
+ USHORT Xmts_InProgress ;
+ USHORT CU_Starts ;
+ USHORT Xmt_Completes ;
+
+// [ RAM locations 00F0-00FF ]
+
+ ULONG Up_Time ;
+ USHORT missing_EOFs ;
+ USHORT Transmitter_Hangs ;
+ USHORT Receiver_Hangs ;
+ USHORT reset_anomaly_count ;
+ USHORT res2[2] ;
+
+// [ RAM locations 0100-010F ]
+
+ USHORT SCB[8];
+
+//SCB LABEL WORD ; The 82586's "System Control Block".
+// dw 0 ; STAT, CUS, and RUS.
+// dw 0 ; ACK, CUC, RESET, and RUC.
+// dw 0FFFFh ; Command Block List.
+// dw 0FFFFh ; Receive Frame Area.
+// dw 0 ; Cyclic Redundancy Check errors.
+// dw 0 ; Alignment errors.
+// dw 0 ; No Receive Resources errors.
+// dw 0 ; Receive Unit Bus Overrun errors.
+
+//; [ RAM locations 0110-011F ]
+
+ UCHAR dummy_RDB [10];
+
+//dummy_RBD dw 0 ; EOF, F, and Actual Count.
+// dw 0FFFFh ; Pointer to next RBD.
+// dw dummy_buffer-SegmentBase ; 16 LSBs of buffer
+// ; address.
+// db 0 ; 4 MSBs of buffer address.
+// db 0 ; Unused.
+// dw 8002h ; EOL and buffer size.
+
+ USHORT dummy_buffer [6];
+
+//dummy_buffr dw 0 ; The 2-byte dummy buffer.
+// dw 2 dup (0) ; [Unused.]
+//
+
+// [ RAM locations 0120-7FFF (or 3FFF) ]
+
+ UCHAR Start_Here[];
+
+ } LOWNIUDATA, *PLOWNIUDATA;
+
+
+typedef struct _SimpleRingBufferDesc {
+ UCHAR SRB_WritePtr[2];
+ UCHAR SRB_ReadPtr[2];
+ UCHAR SRB_ObjectMap;
+ UCHAR pad[11];
+ USHORT SRB_Offsets[256];
+ } SimpleRingBufferDescriptor;
+
+
+
+
+
+
+typedef volatile struct tagUpNIUData {
+// [ RAM locations 8000-800F ]
+ UCHAR szFreeTBDs[14];
+ USHORT FreeTBDs_RingBuffer;
+
+// [ RAM locations 8010-801F ]
+ UCHAR szXmitFrames[14];
+ USHORT XmtFrames_RingBuffer;
+
+
+// [ RAM locations 8020-802F ]
+ UCHAR szRcvFrames[14];
+ USHORT RcvFrames_RingBuffer;
+
+
+// [ RAM locations 8030-803F ]
+ UCHAR szReturnedRBD[14];
+ USHORT ReturnedRBDs_RingBuffer;
+
+// [ RAM locations 8040-804F ]
+ UCHAR szRequests[14];
+ USHORT Request_RingBuffer;
+
+// [ RAM locations 8050-805F ]
+ UCHAR szResult[14];
+ USHORT Result_RingBuffer;
+
+
+// [ RAM locations 8060-826F ]
+ SimpleRingBufferDescriptor RcvFrames;
+
+//RcvFrames SimpleRingBufferDescriptor <>
+// dw 256 dup (0)
+
+
+// [ RAM locations 8270-847F ]
+ SimpleRingBufferDescriptor ReturnedRBDs;
+
+//ReturnedRBDs SimpleRingBufferDescriptor <>
+// dw 256 dup (0)
+
+
+// [ RAM locations 8480-868F ]
+ SimpleRingBufferDescriptor FreeTDBs;
+
+//FreeTBDs SimpleRingBufferDescriptor <>
+// dw 256 dup (0)
+
+
+// [ RAM locations 8690-889F ]
+ SimpleRingBufferDescriptor XmtFrames;
+
+//XmtFrames SimpleRingBufferDescriptor <>
+// dw 256 dup (0)
+
+
+// [ RAM locations 88A0-8xxx ]
+
+ USHORT System_State ;
+ USHORT System_Modes ;
+ USHORT Last_Timer_0_Count ;
+ USHORT RU_Start_Timeouts ;
+ USHORT _82586_CA_Address ;
+ USHORT _82586_RESET_Address ;
+ USHORT HostInterruptPort ;
+ USHORT AdapterControlPort ;
+ USHORT IRQ_Select_and_LED_Port ;
+ USHORT DeadmanTimerPort ;
+ USHORT HostInterruptLevel ;
+ USHORT HostWindowMask ;
+ USHORT NOT_HostWindowMask ;
+
+ USHORT MinimumHostWindowSize ;
+
+ ULONG HostWindowSize ;
+
+ UCHAR HostOpSys ;
+ UCHAR NIU_AdapterType ;
+ USHORT check_RU_counters_delay ;
+ USHORT Timeout_TCB ;
+ USHORT Xmt_Timestamp ;
+ USHORT Xmt_Timeout ;
+ USHORT initial_RcvFrames_pointer ;
+ USHORT Rcv_Timestamp ;
+ USHORT Rcv_Timeout ;
+ USHORT Diagnostic_Hangs ;
+ USHORT Diagnostic_Timestamp ;
+ USHORT Diagnostic_Timeout ;
+ USHORT Loopback_1st_RBD ;
+ USHORT Loopback_Frame_Length ;
+ USHORT Loopback_Frame_Failures ;
+ ULONG Loopback_Frame_Count ;
+
+ USHORT Max_Multicast_Addresses ;
+ USHORT Max_Multicast_Count ;
+ USHORT Multicast_Padding ;
+ USHORT Max_General_Requests ;
+
+ USHORT Code_and_Xmt_Segment ;
+ USHORT RcvBufferSeg ;
+ USHORT XmtBufferSeg ;
+ USHORT Rcv_Buffer_Size ;
+ USHORT Number_of_Rcv_Buffers ;
+ USHORT Xmt_Buffer_Size ;
+ USHORT Number_of_Xmt_Buffers ;
+ USHORT Rcv_Buffer_Start ;
+ USHORT TCB_Start ;
+ USHORT TBD_Start ;
+ USHORT Xmt_Buffer_Start ;
+ USHORT Room_Left_in_1st_32K ;
+ UCHAR Map_Table[32] ;
+ USHORT Max_Receive_Size ;
+ USHORT Min_Receive_Size ;
+ USHORT Max_Collisions ;
+
+ UCHAR user_FIFO_Threshold ;
+ UCHAR user_PreambleLength ;
+ UCHAR user_CRC_Polynomial ;
+ UCHAR user_InterframeSpacing ;
+ USHORT user_SlotTime ;
+ UCHAR user_MaxRetries ;
+ UCHAR user_LinearPriority ;
+ UCHAR user_ACR_Priority ;
+ UCHAR user_BackoffMethod ;
+ UCHAR user_CRS_Filter ;
+ UCHAR user_CDT_Filter ;
+ UCHAR user_Min_Frame_Length ;
+
+ UCHAR LED_Off_12Volts_DoParityCheck ;
+ UCHAR LED_On_12Volts_DoParityCheck ;
+ UCHAR LED_Off_and_IRQ_Select ;
+ UCHAR LED_On_and_IRQ_Select ;
+
+ UCHAR LED_Status; // added to blink LED. brianlie 12/23/93
+
+// EVEN
+ UCHAR pad00[2];
+
+ USHORT Next_Unused_Location_in_1st_32K ;
+ USHORT Next_Unused_Location_in_2nd_32K ;
+
+ USHORT RFD_Queue[2] ; //head=0, tail=1
+ USHORT Free_RDB_Queue[2] ;
+ USHORT TCB_Queue[2] ;
+
+ X86ADDRESS Default_Address_Base ;
+ X86ADDRESS SCP_Base ;
+
+
+ USHORT Last_CRCERRS ;
+ USHORT Last_ALNERRS ;
+ USHORT Last_RSCERRS ;
+ USHORT Last_OVRNERRS ;
+
+// ALIGN 16
+ UCHAR pad01[22];
+
+ UCHAR ISCP[8];
+
+//ISCP LABEL WORD ; The 82586's "Intermediate System
+// ; Configuration Pointer".
+// db 0 ; Initialization-in-progress flag.
+// db 0 ; [Unused.]
+// dw 0 ; Offset of SCB from SCB Base.
+// dw 0 ; Low order bits of SCB base address.
+// db 0 ; High order bits of SCB base address.
+// db 0 ; [Unused.]
+
+// ALIGN 16
+ UCHAR pad02[24];
+
+ UCHAR szStack[16];
+ USHORT Stack_Area[64];
+
+
+
+
+// ;************************************************
+// ;* Initial Entry Point code *
+// ;************************************************
+ UCHAR Startup_Code[8];
+ USHORT Startup_Code_CS_fixup;
+
+//Startup_Code LABEL BYTE
+// dw 0 ; MOV AX,CS ; These instructions
+// dw 0 ; MOV DS,AX ; are put here during
+// db 0 ; JMP ; initialization.
+// dw 0 ; 0000
+//Startup_Code_CS_fixup LABEL WORD
+// dw 0 ; NIU Code Segment
+
+//;;;;; debugging
+// EVEN
+ UCHAR pad03[2];
+
+//LogStart EQU 0A000h
+//LogEnd EQU 0A000h+(16*1024)
+ USHORT LogFlg;
+ USHORT LopPtr;
+
+//;;;;; debugging
+
+// ALIGN 16
+
+
+// ;************************************************
+// ;* 82586 Runtime Diagnostic Commands *
+// ;************************************************
+
+//; This is the list of commands we give to the 82586 when we perform
+//; the "InitiateDiagnostics" request from the Protocol driver.
+
+//RuntimeDiagnosticCommands LABEL WORD
+
+ USHORT NOP_command[3];
+//NOP_command LABEL WORD
+// dw 0 ; C, B, and other status bits.
+// dw 0000h ; CMD = NOP.
+// dw DIAGNOSE_command-SegmentBase
+
+ USHORT DIAGNOSE_Command[3];
+//DIAGNOSE_command LABEL WORD
+// dw 0 ; C, B, and other status bits.
+// dw 0007h ; CMD = DIAGNOSE.
+// dw TDR_command-SegmentBase
+
+ USHORT TDR_command[3];
+//TDR_command LABEL WORD
+// dw 0 ; C, B, and other status bits.
+// dw 8005h ; EOL = 1 and CMD = TDR.
+// dw 0000h ; This is the last command.
+
+ USHORT TDR_result;
+
+//; Bits in the high byte of "TDR_result":
+
+#define TDR_LinkOK 80h
+#define TDR_TransceiverCableProblem 40h
+#define TDR_Open 20h
+#define TDR_Short 10h
+
+
+
+// ALIGN 16
+ UCHAR pad04[28];
+
+// ;************************************************
+// ;* 82586 Initialization Commands *
+// ;************************************************
+
+//; This is the list of commands we give to the 82586 when we first
+//; start it, when we restart it after we have detected that it is hung,
+//; and when we restart it in performing certain of the "GeneralRequest"s.
+//; There are 4 commands, linked together through their "CB_Link" fields.
+//; The first and third commands are "Configure" commands, and the second
+//; one is an "Individual Address Set Up" command. The two "Configure"
+//; commands specify the same configuration parameters, except that the first
+//; one turns on "internal loopback" mode and the last one turns it off.
+//; We put the 82586 in "internal loopback" mode while it processes the
+//; "Individual Address Set Up" command because it may otherwise not process
+//; it correctly. The fourth command is a "Multicast Address Set Up" command.
+//; NOTE that these command blocks get initialized at run time (by the
+//; "_82586_Initialization" routine). The initial values in the following
+//; declarations are effectively just comments.
+
+//_82586_Initialization_Commands LABEL WORD
+
+ USHORT Configure_with_Loopback[9];
+ USHORT individual_Address[3];
+ UCHAR Our_Address[6];
+ USHORT Operation_Configure[4];
+ USHORT Save_Bad_Frames[3];
+ USHORT Promiscuous_ect[2];
+ USHORT Multicast_Setup[3];
+ USHORT Multicast_Byte_Count;
+ CHAR Dynamically_Allocated_Area[][6];
+
+
+//Configure_with_Loopback LABEL WORD
+// dw 0 ; C, B, and other status bits.
+// dw 0002h ; CMD = Configure.
+// dw Individual_Address-SegmentBase
+// db 12 ; Byte count of this block.
+// db 15 ; FIFO limit = 15.
+// db 40h ; Don't save bad frames; External READY sync.
+// db 40h+2Eh ; Internal loopback; 8-byte preamble; Address
+// ; and Type in data buffer; 6 address bytes.
+// db 0 ; IEEE 802.3 exponential backoff method.
+// db 96 ; Interframe spacing = 96.
+// dw 0F200h ; 15 retries on collisions; Slot time = 512.
+// db 0 ; Non-promiscuous; Broadcasts accepted.
+// db 0 ; Externally generated Carrier Sense (CRS) and
+// ; Collision Detect (CDT); CRS filter and CDT
+// ; filter = 0.
+// dw 12 ; Minimum frame length.
+//
+//Individual_Address LABEL WORD
+// dw 0 ; C, B, and other status bits.
+// dw 0001h ; CMD = Individual Address Set Up.
+// dw Operational_Configure-SegmentBase
+//Our_Address LABEL BYTE
+// dw 3 dup (0) ; The address is filled in at initialization.
+//
+//Operational_Configure LABEL WORD
+// dw 0 ; C, B, and other status bits.
+// dw 0002h ; CMD = Configure.
+// dw Multicast_Setup-SegmentBase
+// db 12 ; Byte count of this block.
+// db 15 ; FIFO limit = 15.
+//Save_Bad_Frames_etc LABEL BYTE
+// db 40h ; Don't save bad frames; External READY sync.
+// db 2Eh ; 8-byte preamble; Address and Type in data
+// ; buffer; 6 address bytes.
+// db 0 ; IEEE 802.3 exponential backoff method.
+// db 96 ; Interframe spacing = 96.
+// dw 0F200h ; 15 retries on collisions; Slot time = 512.
+//Promiscuous_etc LABEL BYTE
+// db 08h ; Non-promiscuous; Broadcasts accepted;
+// ; TONO-CRS.
+// db 0 ; Externally generated Carrier Sense (CRS) and
+// ; Collision Detect (CDT); CRS filter and CDT
+// ; filter = 0.
+// dw 12 ; Minimum frame length.
+//
+//Multicast_Setup LABEL WORD
+// dw 0 ; C, B, and other status bits.
+// dw 8003h ; End-of-List=1; CMD=Multicast Address Setup.
+// dw 0 ; [This is the last initialization command.]
+// dw 0 ; This 0 means disable multicast addresses.
+//
+//Dynamically_Allocated_Area LABEL BYTE
+//
+//; The RAM from here up is allocated by "Initialize_Data". It is used for
+//; (a) the Multicast-Setup Command Block's list of multicast addresses;
+//; (b) the RFDs (Receive Frame Descriptors), if they won't fit in the
+//; first 32K;
+//; (c) the TCBs (Transmit Command Blocks);
+//; (d) the TBDs (Transmit Buffer Descriptors);
+//; (e) the "Request" ring buffer; and
+//; (f) the "Result" ring buffer;
+//; NOTE that the Multicast-Setup Command Block's header must immediately
+//; precede this area, and the space for the list of multicast addresses must
+//; be the first thing allocated, because the list must be contiguous with the
+//; header.
+//
+//
+//;NIU_DataSegment ENDS
+//
+
+
+
+ } HIGHNIUDATA, *PHIGHNIUDATA;
+
+
+typedef volatile struct _NIU_CONTROL_AREA {
+
+ USHORT us_POD_SCB[8]; // xFF00 - 586 SCB (if Ethernet).
+ UCHAR uc_Aux_port; // xFF10 - Aux Control port value last output.
+ UCHAR uc_Aux_reserved;
+ UCHAR uc_ADP_port; // xFF12 - Adapter Control port value.
+ UCHAR uc_ADP_reserved;
+ UCHAR uc_UnusedInfo1[108]; // uninteresting stuff.
+ USHORT us_pod_status; // xFF80 - current Power-On Diag (POD) status.
+ USHORT us_sif_test; // xFF82 - request to test SIF chip.
+ UCHAR uc_UnusedInfo2[12];
+ USHORT us_HWstatus; // xFF90 - status results of POD.
+ USHORT us_HWcommand; // xFF92 - command from PC to PROM.
+ USHORT us_HWresult1; // xFF94 - results of last command from PC.
+ USHORT us_HWresult2; // xFF96 - more results of last command.
+ USHORT us_HWparameter1; // xFF98 - command parameter 1.
+ USHORT us_HWparameter2; // xFF9A - command parameter 2.
+ UCHAR uc_rsrvd_for_PCuse[36];
+ USHORT us_DI_value; // xFFC0 - value of PROM's DI.
+ USHORT us_SI_value; // xFFC2 - value of PROM's SI.
+ USHORT us_BP_value; // xFFC4 - value of PROM's BP.
+ UCHAR uc_unknown1[2]; // xFFC6 - reserved.
+ USHORT us_BX_value; // xFFC8 - value of PROM's BX.
+ USHORT us_DX_value; // xFFCA - value of PROM's DX.
+ USHORT us_CX_value; // xFFCC - value of PROM's CX.
+ USHORT us_AX_value; // xFFCE - value of PROM's AX.
+ USHORT us_ES_value; // xFFD0 - value of PROM's ES.
+ USHORT us_DS_value; // xFFD2 - value of PROM's DS.
+ USHORT us_SP_value; // xFFD4 - value of PROM's SP.
+ USHORT us_SS_value; // xFFD6 - value of PROM's SS.
+ USHORT us_IP_value; // xFFD8 - value of PROM's IP.
+ USHORT us_CS_value; // xFFDA - value of PROM's CS.
+ USHORT us_Flags_value; // xFFDC - value of PROM's Flags.
+ UCHAR uc_interrupt_type; // xFFDE - Interrupt type (?).
+ UCHAR uc_reserved1;
+ UCHAR uc_board_rev; // xFFE0 - board revision level.
+ UCHAR uc_board_sub_rev; // xFFE1 - board sub-revision level.
+ UCHAR uc_banks_of_RAM; // xFFE2 - number of 64k banks of RAM.
+ UCHAR uc_host_type; // xFFE3 - type of host.
+ UCHAR uc_media_type; // xFFE4 - type of media interface:
+ UCHAR uc_product_type; // xFFE5 - type of product.
+ USHORT us_clock_speed; // xFFE6 - NIU CPU clock rate.
+ UCHAR uc_POD_ISCP[8]; // xFFE8 - 586 ISCP (if Ethernet).
+ UCHAR uc_node_id[6]; // xFFF0 - the NIU's 48-bit node address.
+ USHORT us_POD_SCP; // xFFF6 - 586 SCP (if Ethernet).
+ UCHAR uc_hdlc_flag; // xFFF8 - HDLC flag (if Ethernet).
+} NIU_CONTROL_AREA, *PNIU_CONTROL_AREA;
+
+
+
+
+#include "packoff.h"
diff --git a/private/ntos/ndis/ubnei/receive.c b/private/ntos/ndis/ubnei/receive.c
new file mode 100644
index 000000000..6cfb38a29
--- /dev/null
+++ b/private/ntos/ndis/ubnei/receive.c
@@ -0,0 +1,482 @@
+/*++
+
+Copyright (c) 1992 Microsoft Corporation
+
+Module Name:
+
+ receive.c
+
+Abstract:
+
+ This file handles received packets the Ungermann Bass Ethernet Controller.
+ This driver conforms to the NDIS 3.0 interface.
+
+ Based on the elnkii drivers for the most part
+
+Author:
+ Brian Lieuallen (BrianLie) 07/02/92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's
+
+Revision History:
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+--*/
+
+
+
+#include <ndis.h>
+#include <efilter.h>
+
+#include "niudata.h"
+#include "debug.h"
+#include "ubhard.h"
+#include "ubsoft.h"
+#include "ubnei.h"
+
+#include "map.h"
+
+
+
+
+
+BOOLEAN
+CheckForReceives(
+ IN PUBNEI_ADAPTER pAdapter
+ )
+/*++
+
+Routine Description:
+
+ This routine is called from the interrupt DPC to check the card for
+ received packets. If it finds one then it calls the ethfilter indicate
+ it to the correct protocols
+
+
+Arguments:
+
+
+Notes:
+
+
+
+--*/
+
+
+{
+
+ PHIGHNIUDATA pDataWindow = (PHIGHNIUDATA) pAdapter->pDataWindow;
+ PRBD pRBD;
+ UINT PacketLength,LookAheadSize;
+ PUCHAR pBuffer;
+ USHORT rbdtemp;
+ USHORT TmpUshort;
+ UCHAR TmpUchar1, TmpUchar2;
+ PUCHAR LookaheadBuffer;
+
+
+ SET_DATAWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ // NumberOfPackets=pDataWindow->RcvFrames.SRB_WritePtr[0]-
+ // pDataWindow->RcvFrames.SRB_ReadPtr[0];
+
+ //
+ // Check to see if the are any recieved frames in the ring buffer
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar1, &(pDataWindow->RcvFrames.SRB_ReadPtr[0]));
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar2, &(pDataWindow->RcvFrames.SRB_WritePtr[0]));
+
+ if (TmpUchar1 == TmpUchar2) {
+ SET_RECDWINDOW(pAdapter,INTERRUPT_ENABLED);
+ return FALSE;
+ }
+
+ //
+ // There is at least one packet to indicate
+ //
+
+ // SRB- stands for Simple Ring Buffer
+ // The main components of interest are the Read and Write pointers
+ // and the offset array.
+ //
+ // The value in the R/W ptr is actually an index into the Offset
+ // array. The values in the offset array are offsets to RBD's
+ //
+ // RDB- Receive Buffer Descriptor
+ // The structure holds the address of the actual receive data, its
+ // its length and perhaps a link to the next RDB that makes up
+ // a given packet
+ //
+ // The RDB's and the actual receive buffers are all in the first
+ // half of the 64k data segment. If the window size is only 16k then
+ // only 16k will be used, otherwise the whole 32k will be used
+ //
+
+
+ //
+ // We do receive indications until there are no more or reset starts
+ //
+
+ while ((TmpUchar1 != TmpUchar2)) {
+
+
+ //
+ // Get the offset of the first RBD, used in freeing the RBD chain
+ // when the receive is complete
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&rbdtemp,
+ &(pDataWindow->RcvFrames.SRB_Offsets[TmpUchar1])
+ );
+
+ //
+ // Get a pointer to the RBD the data window
+ //
+
+ pRBD=(PRBD)((PUCHAR)pAdapter->pCardRam+rbdtemp);
+
+ SET_RECDWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ //
+ // Get the address of the first buffer pointed to by this RBD
+ // All of the receive buffers are in the receive segment
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pRBD->RBD_Buffer));
+
+ pBuffer=(PUCHAR)pAdapter->pCardRam+TmpUshort;
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pRBD->RBD_Frame_Length));
+
+ PacketLength=TmpUshort;
+
+ LookAheadSize=PacketLength < pAdapter->ReceiveBufSize ?
+ PacketLength : pAdapter->ReceiveBufSize;
+
+ IF_LOG('y');
+
+ if (PacketLength >= 14) {
+
+ NdisCreateLookaheadBufferFromSharedMemory(
+ pBuffer,
+ LookAheadSize,
+ &LookaheadBuffer
+ );
+
+ if (LookaheadBuffer != NULL) {
+
+ //
+ // We save this information in the Adapter block for use of the
+ // TransferData
+ //
+ pAdapter->pIndicatedRBD=pRBD;
+ pAdapter->PacketLen=PacketLength;
+
+ //
+ // Save this for transfer data, so probably won't have to get this out
+ // of the shared ram again
+ //
+ pAdapter->FirstCardBuffer=pBuffer;
+
+
+ NdisMEthIndicateReceive(
+ pAdapter->NdisAdapterHandle,
+ NULL,
+ LookaheadBuffer,
+ 14,
+ (PUCHAR)LookaheadBuffer + 14,
+ LookAheadSize -14,
+ PacketLength-14
+ );
+
+
+
+ NdisDestroyLookaheadBufferFromSharedMemory(LookaheadBuffer);
+
+ }
+
+ }
+
+ IF_LOG('Y');
+
+ SET_DATAWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ //
+ // Free the RBDs by placing the the first RBD in the returned RBDs
+ // ring buffer
+ //
+
+ TmpUchar1++;
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->RcvFrames.SRB_ReadPtr[0]), TmpUchar1);
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar2,
+ &(pDataWindow->ReturnedRBDs.SRB_WritePtr[0])
+ );
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pDataWindow->ReturnedRBDs.SRB_Offsets[TmpUchar2]),
+ rbdtemp
+ );
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->ReturnedRBDs.SRB_WritePtr[0]),
+ TmpUchar2 + 1
+ );
+ //
+ // read the ring pointers again for the main while loop
+ //
+// UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar1, &(pDataWindow->RcvFrames.SRB_ReadPtr[0]));
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar2, &(pDataWindow->RcvFrames.SRB_WritePtr[0]));
+
+ }
+
+ SET_RECDWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ IF_LOG('z');
+
+
+ //
+ // If we get here we know that at least one packet was indicated
+ //
+
+ NdisMEthIndicateReceiveComplete(pAdapter->NdisAdapterHandle);
+
+
+ IF_LOG('Z');
+
+ return TRUE;
+}
+
+
+
+
+
+
+NDIS_STATUS
+UbneiTransferData(
+ OUT PNDIS_PACKET Packet,
+ OUT PUINT BytesTransferred,
+ IN NDIS_HANDLE MacBindingHandle,
+ IN NDIS_HANDLE MacReceiveContext,
+ IN UINT ByteOffset,
+ IN UINT BytesToTransfer
+ )
+
+
+/*++
+
+Routine Description:
+
+ NDIS function.
+
+Arguments:
+
+ see NDIS 3.0 spec.
+
+Notes:
+
+ This routine uses two elements in the Adapter structure to pass
+ information about the current indication. This will only work because
+ there can be only one indication going on at a time.
+
+
+--*/
+
+{
+ UINT BytesLeft, BytesNow, BytesWanted;
+ PNDIS_BUFFER CurBuffer;
+ PUCHAR BufStart;
+ UINT BufLen;
+ UINT BufferIndex, i;
+ PUCHAR pBuffer;
+ PUBNEI_ADAPTER pAdapter = MacBindingHandle;
+ PRBD pRBD = pAdapter->pIndicatedRBD;
+ UINT CardBufferSize = pAdapter->ReceiveBufSize;
+ USHORT TmpUshort;
+
+ UINT BytesLeftInCardBuffer;
+
+
+
+ ByteOffset += 14;
+
+
+
+ //
+ // See how much data there is to transfer.
+ //
+
+
+ if (ByteOffset+BytesToTransfer > pAdapter->PacketLen) {
+
+ IF_LOUD(DbgPrint("TD() Protocol asked for too much data\n");)
+ BytesWanted = pAdapter->PacketLen - ByteOffset;
+
+ } else {
+
+ BytesWanted = BytesToTransfer;
+
+ }
+
+ BytesLeft = BytesWanted;
+
+
+ //
+ // Determine where the copying should start.
+ //
+
+
+ IF_LOG('t');
+
+ ASSERT_RECEIVE_WINDOW( pAdapter);
+
+// SET_RECDWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+
+ ByteOffset=ByteOffset;
+
+ BytesLeftInCardBuffer=CardBufferSize-ByteOffset;
+
+ pBuffer=pAdapter->FirstCardBuffer;
+
+ pBuffer+=ByteOffset;
+
+ if (ByteOffset>CardBufferSize) {
+ //
+ // The transfer start point is not in the first card buffer.
+ // Move the correct one.
+ //
+ // The is definitly the exception case
+ //
+ BufferIndex=ByteOffset/CardBufferSize;
+
+ for (i=0;i<BufferIndex;i++) {
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pRBD->RBD_next_RBD));
+
+ pRBD=(PRBD)((PUCHAR)pAdapter->pCardRam+ TmpUshort);
+
+ ByteOffset-=CardBufferSize;
+
+ }
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pRBD->RBD_Buffer));
+
+ BytesLeftInCardBuffer=CardBufferSize-ByteOffset;
+
+ pBuffer=(PUCHAR)pAdapter->pCardRam+TmpUshort;
+
+ pBuffer+=ByteOffset;
+
+ }
+
+
+ NdisQueryPacket(Packet, NULL, NULL, &CurBuffer, NULL);
+
+ NdisQueryBuffer(CurBuffer, (PVOID *)&BufStart, &BufLen);
+
+ //
+ // Loop, filling each buffer in the packet until there
+ // are no more buffers or the data has all been copied.
+ //
+
+ while (BytesLeft > 0) {
+
+ BytesNow = BytesLeft;
+
+ //
+ // See how much room is in the current ndis buffer
+ //
+ if (BufLen < BytesLeft) {
+
+ BytesNow = BufLen;
+
+ }
+
+ //
+ // See how much room is left in the current card buffer
+ //
+ if (BytesNow > BytesLeftInCardBuffer) {
+
+ BytesNow = BytesLeftInCardBuffer;
+
+ }
+
+ //
+ // Copy up the data.
+ //
+ UBNEI_MOVE_SHARED_RAM_TO_MEM(BufStart, pBuffer, BytesNow);
+
+ BufStart += BytesNow;
+
+ BufLen -= BytesNow;
+
+
+ pBuffer += BytesNow;
+
+ BytesLeftInCardBuffer -= BytesNow;
+
+
+ BytesLeft -= BytesNow;
+
+
+ //
+ // Is the transfer done now?
+ //
+
+ if (BytesLeft == 0) {
+
+ break;
+
+ }
+
+
+ //
+ // Did we use up the card buffer?
+ //
+ if (BytesLeftInCardBuffer == 0) {
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pRBD->RBD_next_RBD));
+
+ pRBD=(PRBD)((PUCHAR)pAdapter->pCardRam+TmpUshort);
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TmpUshort, &(pRBD->RBD_Buffer));
+
+
+ pBuffer=(PUCHAR)pAdapter->pCardRam+TmpUshort;
+
+ BytesLeftInCardBuffer=CardBufferSize;
+
+ }
+
+
+ //
+ // Was the end of this packet buffer reached?
+ //
+ if (BufLen==0) {
+
+ NdisGetNextBuffer(CurBuffer, &CurBuffer);
+
+ if (CurBuffer == (PNDIS_BUFFER)NULL) {
+
+ break;
+
+ }
+
+ NdisQueryBuffer(CurBuffer, (PVOID *)&BufStart, &BufLen);
+
+ }
+
+ }
+
+
+ *BytesTransferred = BytesWanted - BytesLeft;
+
+ IF_LOG('T');
+
+
+ return NDIS_STATUS_SUCCESS;
+
+}
diff --git a/private/ntos/ndis/ubnei/request.c b/private/ntos/ndis/ubnei/request.c
new file mode 100644
index 000000000..b3c937719
--- /dev/null
+++ b/private/ntos/ndis/ubnei/request.c
@@ -0,0 +1,713 @@
+/*++
+
+Copyright (c) 1992 Microsoft Corporation
+
+Module Name:
+
+ request.c
+
+Abstract:
+
+ Ndis 3.0 MAC driver for the UB card
+
+ This file handles NdisRequest. The module was for the most part extracted
+ from the elnkii driver
+
+Author:
+
+ Brian Lieuallen (BrianLie) 07/02/92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's
+
+Revision History:
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+
+--*/
+
+
+
+
+
+#include <ndis.h>
+//#include <efilter.h>
+
+
+
+#include "niudata.h"
+#include "debug.h"
+#include "ubhard.h"
+#include "ubsoft.h"
+#include "ubnei.h"
+
+
+
+
+
+
+
+NDIS_STATUS
+UbneiFilterChangeAction(
+ IN UINT NewFilterClasses,
+ IN NDIS_HANDLE MacBindingHandle
+ );
+
+
+
+
+
+//
+// If you add to this, make sure to add the
+// a case in UbneiFillInGlobalData() and in
+// UbneiQueryGlobalStatistics() if global
+// information only or
+// UbneiQueryProtocolStatistics() if it is
+// protocol queriable information.
+//
+STATIC UINT UbneiGlobalSupportedOids[] = {
+ OID_GEN_SUPPORTED_LIST,
+ OID_GEN_HARDWARE_STATUS,
+ OID_GEN_MEDIA_SUPPORTED,
+ OID_GEN_MEDIA_IN_USE,
+ OID_GEN_MAXIMUM_LOOKAHEAD,
+ OID_GEN_MAXIMUM_FRAME_SIZE,
+ OID_GEN_MAXIMUM_TOTAL_SIZE,
+ OID_GEN_MAC_OPTIONS,
+ OID_GEN_PROTOCOL_OPTIONS,
+ OID_GEN_LINK_SPEED,
+ OID_GEN_TRANSMIT_BUFFER_SPACE,
+ OID_GEN_RECEIVE_BUFFER_SPACE,
+ OID_GEN_TRANSMIT_BLOCK_SIZE,
+ OID_GEN_RECEIVE_BLOCK_SIZE,
+ OID_GEN_VENDOR_ID,
+ OID_GEN_VENDOR_DESCRIPTION,
+ OID_GEN_DRIVER_VERSION,
+ OID_GEN_CURRENT_PACKET_FILTER,
+ OID_GEN_CURRENT_LOOKAHEAD,
+ OID_GEN_XMIT_OK,
+ OID_GEN_RCV_OK,
+ OID_GEN_XMIT_ERROR,
+ OID_GEN_RCV_ERROR,
+ OID_GEN_RCV_NO_BUFFER,
+ OID_802_3_PERMANENT_ADDRESS,
+ OID_802_3_CURRENT_ADDRESS,
+ OID_802_3_MULTICAST_LIST,
+ OID_802_3_MAXIMUM_LIST_SIZE,
+ OID_802_3_RCV_ERROR_ALIGNMENT,
+ OID_802_3_XMIT_ONE_COLLISION,
+ OID_802_3_XMIT_MORE_COLLISIONS
+ };
+
+
+
+
+
+
+NDIS_STATUS
+UbneiQueryInformation(
+ IN NDIS_HANDLE MiniportContext,
+ IN NDIS_OID Oid,
+ IN PVOID InfoBuffer,
+ IN ULONG BytesLeft,
+ OUT PULONG BytesWritten,
+ OUT PULONG BytesNeeded
+ )
+
+/*++
+
+Routine Description:
+
+ The UbneiQueryProtocolInformation process a Query request for
+ NDIS_OIDs that are specific to a binding about the MAC. Note that
+ some of the OIDs that are specific to bindings are also queryable
+ on a global basis. Rather than recreate this code to handle the
+ global queries, I use a flag to indicate if this is a query for the
+ global data or the binding specific data.
+
+Arguments:
+
+ Adapter - a pointer to the adapter.
+
+ Oid - the NDIS_OID to process.
+
+ PlaceInInfoBuffer - a pointer into the NdisRequest->InformationBuffer
+ into which store the result of the query.
+
+ BytesLeft - the number of bytes left in the InformationBuffer.
+
+ BytesNeeded - If there is not enough room in the information buffer
+ then this will contain the number of bytes needed to complete the
+ request.
+
+ BytesWritten - a pointer to the number of bytes written into the
+ InformationBuffer.
+
+Return Value:
+
+ The function value is the status of the operation.
+
+--*/
+
+{
+
+
+ NDIS_MEDIUM Medium = NdisMedium802_3;
+ ULONG GenericULong = 0;
+ USHORT GenericUShort = 0;
+ UCHAR GenericArray[6];
+
+ PUBNEI_ADAPTER pAdapter=MiniportContext;
+
+ PLOWNIUDATA pRcvDWindow = (PLOWNIUDATA) pAdapter->pCardRam;
+
+ NDIS_STATUS StatusToReturn = NDIS_STATUS_SUCCESS;
+
+ //
+ // Common variables for pointing to result of query
+ //
+
+ PVOID MoveSource;
+ ULONG MoveBytes;
+
+ NDIS_HARDWARE_STATUS HardwareStatus = NdisHardwareStatusReady;
+
+ //
+ // General Algorithm:
+ //
+ // Switch(Request)
+ // Get requested information
+ // Store results in a common variable.
+ // Copy result in common variable to result buffer.
+ //
+
+ //
+ // Make sure that ulong is 4 bytes. Else GenericULong must change
+ // to something of size 4.
+ //
+ ASSERT(sizeof(ULONG) == 4);
+
+
+ IF_REQ_LOUD(DbgPrint("UBNEI: QueryProtocol %08lx\n",Oid);)
+
+ MoveSource = (PVOID)(&GenericULong);
+ MoveBytes = sizeof(GenericULong);
+
+
+ //
+ // Switch on request type
+ //
+
+ switch (Oid) {
+
+ case OID_GEN_MAC_OPTIONS:
+
+
+
+
+ GenericULong = (
+ NDIS_MAC_OPTION_TRANSFERS_NOT_PEND |
+ NDIS_MAC_OPTION_NO_LOOPBACK |
+ NDIS_MAC_OPTION_RECEIVE_SERIALIZED);
+
+
+ break;
+
+ case OID_GEN_SUPPORTED_LIST:
+
+
+ MoveSource = (PVOID)(&UbneiGlobalSupportedOids);
+ MoveBytes = sizeof(UbneiGlobalSupportedOids);
+
+ break;
+
+ case OID_GEN_HARDWARE_STATUS:
+
+ HardwareStatus = NdisHardwareStatusReady;
+
+
+ MoveSource = (PVOID)(&HardwareStatus);
+ MoveBytes = sizeof(NDIS_HARDWARE_STATUS);
+
+ break;
+
+ case OID_GEN_MEDIA_SUPPORTED:
+ case OID_GEN_MEDIA_IN_USE:
+
+ MoveSource = (PVOID) (&Medium);
+ MoveBytes = sizeof(NDIS_MEDIUM);
+ break;
+
+ case OID_GEN_MAXIMUM_LOOKAHEAD:
+
+ GenericULong = pAdapter->ReceiveBufSize-14;
+
+ break;
+
+
+ case OID_GEN_MAXIMUM_FRAME_SIZE:
+
+ GenericULong = (ULONG)(1514 - 14);
+
+ break;
+
+
+ case OID_GEN_MAXIMUM_TOTAL_SIZE:
+
+ GenericULong = (ULONG)(1514);
+
+ break;
+
+
+ case OID_GEN_LINK_SPEED:
+
+ GenericULong = (ULONG)(100000);
+
+ break;
+
+
+ case OID_GEN_TRANSMIT_BUFFER_SPACE:
+
+ GenericULong = pAdapter->TransmitBufferSpace;
+
+ break;
+
+ case OID_GEN_RECEIVE_BUFFER_SPACE:
+
+ GenericULong = pAdapter->ReceiveBufferSpace;
+
+ break;
+
+ case OID_GEN_TRANSMIT_BLOCK_SIZE:
+
+ GenericULong = pAdapter->TransmitBlockSize;
+
+ break;
+
+ case OID_GEN_RECEIVE_BLOCK_SIZE:
+
+ GenericULong = pAdapter->ReceiveBlockSize;
+
+ break;
+
+ case OID_GEN_VENDOR_ID:
+
+ NdisMoveMemory(
+ (PVOID)&GenericULong,
+ pAdapter->PermanentAddress,
+ 3
+ );
+ GenericULong &= 0xFFFFFF00;
+ break;
+
+ case OID_GEN_VENDOR_DESCRIPTION:
+
+ MoveSource = (PVOID)"UBNEI Ethernet Adapter.";
+ MoveBytes = 24;
+
+ break;
+
+ case OID_GEN_DRIVER_VERSION:
+
+ GenericUShort = ((USHORT)UBNEI_NDIS_MAJOR_VERSION << 8) |
+ UBNEI_NDIS_MINOR_VERSION;
+
+ MoveSource = (PVOID)(&GenericUShort);
+ MoveBytes = sizeof(GenericUShort);
+ break;
+
+
+
+ case OID_GEN_CURRENT_LOOKAHEAD:
+
+
+ GenericULong = (ULONG)(pAdapter->MaxLookAhead);
+
+
+
+ IF_REQ_LOUD(DbgPrint("Querying LookAhead: %d\n,GenericULong");)
+
+ break;
+
+ case OID_802_3_PERMANENT_ADDRESS:
+
+ IF_REQ_LOUD(DbgPrint("Querying Permanent address\n");)
+
+ NdisMoveMemory((PCHAR)GenericArray,
+ pAdapter->PermanentAddress,
+ ETH_LENGTH_OF_ADDRESS);
+
+ MoveSource = (PVOID)(GenericArray);
+ MoveBytes = sizeof(pAdapter->PermanentAddress);
+ break;
+
+
+ case OID_802_3_CURRENT_ADDRESS:
+
+ IF_REQ_LOUD(DbgPrint("Querying Current address\n");)
+
+ NdisMoveMemory(
+ (PCHAR)GenericArray,
+ pAdapter->StationAddress,
+ ETH_LENGTH_OF_ADDRESS
+ );
+
+ MoveSource = (PVOID)(GenericArray);
+ MoveBytes = sizeof(pAdapter->StationAddress);
+ break;
+
+
+ case OID_802_3_MAXIMUM_LIST_SIZE:
+
+ GenericULong = (ULONG) DEFAULT_MULTICAST_SIZE;
+
+
+ break;
+
+
+
+
+
+ case OID_GEN_XMIT_OK:
+
+ NdisReadRegisterUlong(
+ &pRcvDWindow->sst.SST_TotalFramesTransmitted,
+ &GenericULong
+ );
+
+ break;
+
+ case OID_GEN_RCV_OK:
+
+ NdisReadRegisterUlong(
+ (PUCHAR)&pRcvDWindow->sst.SST_TotalFramesReceived,
+ &GenericULong
+ );
+
+ break;
+
+ case OID_GEN_XMIT_ERROR:
+
+
+ GenericULong = pAdapter->FramesXmitBad;
+
+
+ break;
+
+ case OID_GEN_RCV_ERROR:
+
+ NdisReadRegisterUlong(
+ (PUCHAR)&pRcvDWindow->sst.SST_FramesReceivedWithErrors,
+ &GenericULong
+ );
+
+ break;
+
+ case OID_GEN_RCV_NO_BUFFER:
+
+ GenericULong = (UINT)(pAdapter->MissedPackets);
+
+ break;
+
+ case OID_802_3_RCV_ERROR_ALIGNMENT:
+
+ GenericULong = (UINT)pAdapter->FrameAlignmentErrors;
+
+ break;
+
+ case OID_802_3_XMIT_ONE_COLLISION:
+
+ GenericULong = (UINT)pAdapter->FramesXmitOneCollision;
+
+
+ break;
+
+ case OID_802_3_XMIT_MORE_COLLISIONS:
+
+ GenericULong = (UINT)pAdapter->FramesXmitManyCollisions;
+
+
+ break;
+
+
+
+ default:
+
+ StatusToReturn = NDIS_STATUS_NOT_SUPPORTED;
+ break;
+ }
+
+ if (StatusToReturn == NDIS_STATUS_SUCCESS) {
+
+ if (MoveBytes > BytesLeft) {
+
+ //
+ // Not enough room in InformationBuffer. Punt
+ //
+
+ *BytesNeeded = MoveBytes;
+
+ StatusToReturn = NDIS_STATUS_INVALID_LENGTH;
+
+ } else {
+
+ //
+ // Store result.
+ //
+
+ NdisMoveMemory(InfoBuffer, MoveSource, MoveBytes);
+
+ (*BytesWritten) = MoveBytes;
+
+ }
+ }
+
+
+#if DBG
+
+ if (StatusToReturn != NDIS_STATUS_SUCCESS) {
+
+ IF_REQ_LOUD(DbgPrint("Out QueryInfo oid=%08lx failed\n",Oid);)
+ }
+#endif
+
+
+ IF_VERY_LOUD( DbgPrint("Out QueryProtocol\n");)
+
+ return StatusToReturn;
+}
+
+
+NDIS_STATUS
+UbneiSetInformation(
+ IN NDIS_HANDLE MiniportContext,
+ IN NDIS_OID Oid,
+ IN PVOID InfoBuffer,
+ IN ULONG BytesLeft,
+ OUT PULONG BytesRead,
+ OUT PULONG BytesNeeded
+ )
+
+/*++
+
+Routine Description:
+
+ The UbneiSetInformation is used by UbneiRequest to set information
+ about the MAC.
+
+Arguments:
+
+ Adapter - A pointer to the adapter.
+
+ Open - A pointer to an open instance.
+
+ NdisRequest - A structure which contains the request type (Set),
+ an array of operations to perform, and an array for holding
+ the results of the operations.
+
+Return Value:
+
+ The function value is the status of the operation.
+
+--*/
+
+{
+
+ //
+ // General Algorithm:
+ //
+ // Verify length
+ // Switch(Request)
+ // Process Request
+ //
+
+ //
+ // Variables for a particular request
+ //
+
+ PUBNEI_ADAPTER pAdapter=MiniportContext;
+
+ UINT OidLength;
+
+ //
+ // Variables for holding the new values to be used.
+ //
+
+ ULONG LookAhead;
+ ULONG Filter;
+
+ NDIS_STATUS StatusToReturn = NDIS_STATUS_SUCCESS;
+
+
+ IF_REQ_LOUD( DbgPrint("Ubnei: SetInfo %08lx %0d\n",(UINT)Oid,BytesLeft);)
+
+ //
+ // Get Oid and Length of request
+ //
+
+
+ OidLength = BytesLeft;
+
+ switch (Oid) {
+
+
+ case OID_802_3_MULTICAST_LIST:
+
+ //
+ // Verify length
+ //
+
+ if ((OidLength % ETH_LENGTH_OF_ADDRESS) != 0){
+
+ StatusToReturn = NDIS_STATUS_INVALID_LENGTH;
+
+ *BytesRead = 0;
+ *BytesNeeded = 0;
+
+ break;
+
+ }
+
+#if DBG
+ {
+ UINT j;
+ PUCHAR Address;
+
+ Address=InfoBuffer;
+
+ for (j=0; j<(OidLength / ETH_LENGTH_OF_ADDRESS); j++) {
+
+ IF_REQ_LOUD(DbgPrint(" %02x-%02x-%02x-%02x-%02x-%02x\n",
+ Address[j*6],
+ Address[j*6+1],
+ Address[j*6+2],
+ Address[j*6+3],
+ Address[j*6+4],
+ Address[j*6+5]);)
+ }
+ }
+#endif
+
+ StatusToReturn=UbneiAddressChangeAction(
+ OidLength,
+ (PUCHAR)InfoBuffer,
+ pAdapter
+ );
+
+ break;
+
+
+ case OID_GEN_CURRENT_PACKET_FILTER:
+
+ //
+ // Verify length
+ //
+
+ if (OidLength != 4 ) {
+
+ StatusToReturn = NDIS_STATUS_INVALID_LENGTH;
+
+ *BytesRead = 0;
+ *BytesNeeded = 0;
+
+ break;
+
+ }
+
+
+
+ NdisMoveMemory(&Filter, InfoBuffer, 4);
+
+
+ StatusToReturn=UbneiFilterChangeAction(
+ Filter,
+ pAdapter
+ );
+
+
+
+
+ break;
+
+ case OID_GEN_CURRENT_LOOKAHEAD:
+
+ //
+ // Verify length
+ //
+ if (OidLength != 4) {
+
+ StatusToReturn = NDIS_STATUS_INVALID_LENGTH;
+
+ *BytesRead = 0;
+ *BytesNeeded = 0;
+
+ break;
+
+ }
+
+ NdisMoveMemory(
+ &LookAhead,
+ InfoBuffer,
+ 4
+ );
+
+ IF_REQ_LOUD(DbgPrint("Setting LookAhead: %d\n",LookAhead);)
+
+
+ if (LookAhead <= pAdapter->ReceiveBufSize-14) {
+
+ pAdapter->MaxLookAhead=LookAhead;
+
+
+ } else {
+
+ StatusToReturn = NDIS_STATUS_INVALID_LENGTH;
+
+ }
+
+ break;
+
+
+ case OID_GEN_PROTOCOL_OPTIONS:
+
+ StatusToReturn = NDIS_STATUS_SUCCESS;
+
+ break;
+
+
+ default:
+
+ StatusToReturn = NDIS_STATUS_INVALID_OID;
+
+ *BytesRead = 0;
+ *BytesNeeded = 0;
+
+ break;
+
+ }
+
+
+ if (StatusToReturn == NDIS_STATUS_SUCCESS) {
+
+ *BytesRead = BytesLeft;
+ *BytesNeeded = 0;
+
+ }
+
+
+#if DBG
+
+ if ((StatusToReturn != NDIS_STATUS_SUCCESS)
+ &&
+ (StatusToReturn != NDIS_STATUS_PENDING)) {
+
+ IF_REQ_LOUD(DbgPrint("Out SetInfo oid=%08lx failed\n",Oid);)
+ }
+#endif
+
+ return StatusToReturn;;
+}
diff --git a/private/ntos/ndis/ubnei/send.c b/private/ntos/ndis/ubnei/send.c
new file mode 100644
index 000000000..ecadbca4d
--- /dev/null
+++ b/private/ntos/ndis/ubnei/send.c
@@ -0,0 +1,369 @@
+/*++
+
+Copyright (c) 1992 Microsoft Corporation
+
+Module Name:
+
+ send.c
+
+Abstract:
+
+ This file handles sending packets the Ungermann Bass Ethernet Controller.
+ This driver conforms to the NDIS 3.0 interface.
+
+
+Author:
+
+ Brian Lieuallen (BrianLie) 07/02/92
+
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's
+
+Revision History:
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+--*/
+
+
+
+#include <ndis.h>
+#include <efilter.h>
+
+#include "niudata.h"
+#include "debug.h"
+
+#include "ubhard.h"
+#include "ubsoft.h"
+#include "ubnei.h"
+
+#include "map.h"
+
+
+BOOLEAN
+CardSend(
+ IN PUBNEI_ADAPTER pAdapter,
+ IN PNDIS_PACKET pPacket,
+ IN UINT PacketLength
+ );
+
+
+
+BOOLEAN
+UbneiMapSendBufferSync(
+ PSEND_SYNC_CONTEXT pSync
+ );
+
+BOOLEAN
+UbneiGiveSendBufferToCardSync(
+ PSEND_SYNC_CONTEXT pSync
+ );
+
+
+
+
+NDIS_STATUS
+UbneiMacSend(
+ IN NDIS_HANDLE MacBindingHandle,
+ IN PNDIS_PACKET pPacket,
+ IN UINT Flags
+ )
+/*++
+
+Routine Description:
+ MacSend
+
+
+Arguments:
+ See NDIS 3.0 spec
+
+Return Value:
+
+
+--*/
+
+
+ {
+ PUBNEI_ADAPTER pAdapter = MacBindingHandle;
+ UINT PacketLength;
+ BOOLEAN SendResult;
+
+ IF_LOG('s');
+
+ ASSERT_RECEIVE_WINDOW( pAdapter);
+
+ IF_SEND_LOUD(DbgPrint("MacSend called Packets\n");)
+
+ NdisQueryPacket(pPacket, NULL, NULL, NULL, &PacketLength);
+
+ //
+ // Here we check to make sure the packet meets some size constraints
+ //
+
+ if (PacketLength < 14 || PacketLength > 1514) {
+
+ IF_LOUD(DbgPrint("MovePacketToCard: Packet too long or too short\n");)
+
+ return NDIS_STATUS_FAILURE;
+
+ }
+
+
+ // No packets queued, so we have a good chance
+ // being able to complete this send right now.
+ // After all the card has enough buffers for
+ // ~32 full size frames.
+ //
+
+ SendResult=CardSend(pAdapter, pPacket, PacketLength);
+
+ if (SendResult) {
+ //
+ // It's gone, were out of here!
+ //
+ // Since we sent it down to the card we don't need the card
+ // to generate an interrupt
+ //
+ ASSERT_RECEIVE_WINDOW( pAdapter);
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(((PLOWNIUDATA)(pAdapter->pCardRam))->HostQueuedTransmits),0);
+
+ NdisMSendResourcesAvailable(pAdapter->NdisAdapterHandle);
+
+ return NDIS_STATUS_SUCCESS;
+
+ } else {
+ //
+ // No card buffers left, queue it and tell the card
+ // to interrupt us when there is room.
+ //
+ IF_LOUD(DbgPrint("UBNEI: No card send resources\n");)
+
+ IF_LOG('o');
+
+ pAdapter->WaitingForXmitInterrupt=TRUE;
+
+ ASSERT_RECEIVE_WINDOW( pAdapter);
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(((PLOWNIUDATA)(pAdapter->pCardRam))->HostQueuedTransmits),1);
+
+ return NDIS_STATUS_RESOURCES;
+ }
+
+
+
+}
+
+
+
+
+
+
+
+BOOLEAN
+CardSend(
+ IN PUBNEI_ADAPTER pAdapter,
+ IN PNDIS_PACKET pPacket,
+ IN UINT PacketLength
+ )
+
+/*++
+
+Routine Description:
+ This routine checks the cards transmit ring buffer to see if
+ a send can take place. If it can then it removes the buffer
+ from the free transmit buffer ring buffer and places it on
+ the to be transimitted ring buffer.
+
+
+Arguments:
+
+ pAdapt - pointer to the adapter block
+
+Return Value:
+ returns TRUE if it was able to copy the send data to the card
+
+ FALSE indicates that there are no free transmit buffers currently
+
+
+--*/
+
+{
+
+ SEND_SYNC_CONTEXT SyncContext;
+
+ BOOLEAN OkToSend;
+
+ SyncContext.pAdapter=pAdapter;
+
+
+ if (PacketLength<60) {
+
+ PacketLength=60;
+
+ }
+
+ SyncContext.PacketLength=PacketLength;
+
+ OkToSend=NdisMSynchronizeWithInterrupt(
+ &pAdapter->NdisInterrupt,
+ UbneiMapSendBufferSync,
+ &SyncContext
+ );
+
+ if (OkToSend) {
+ //
+ // If we can send now the sync routine left the correct
+ // window mapped in for us to copy to the send buffer
+ //
+ {
+ PUCHAR CurAddress, BufAddress;
+ UINT Len;
+ PNDIS_BUFFER CurBuffer;
+
+ //
+ // Memory mapped, just copy each buffer over.
+ //
+
+ NdisQueryPacket(pPacket, NULL, NULL, &CurBuffer, NULL);
+
+ CurAddress = SyncContext.SendBuffer;
+
+ while (CurBuffer) {
+
+ NdisQueryBuffer(CurBuffer, (PVOID *)&BufAddress, &Len);
+
+ UBNEI_MOVE_MEM_TO_SHARED_RAM(CurAddress, BufAddress, Len);
+
+ CurAddress += Len;
+
+ NdisGetNextBuffer(CurBuffer, &CurBuffer);
+
+ }
+
+ }
+
+
+ NdisMSynchronizeWithInterrupt(
+ &pAdapter->NdisInterrupt,
+ UbneiGiveSendBufferToCardSync,
+ &SyncContext
+ );
+
+
+ }
+
+
+ return OkToSend;
+
+
+}
+
+
+BOOLEAN
+UbneiMapSendBufferSync(
+ PSEND_SYNC_CONTEXT pSync
+ )
+
+{
+ PUBNEI_ADAPTER pAdapter=pSync->pAdapter;
+ PHIGHNIUDATA pDataWindow = (PHIGHNIUDATA) pAdapter->pDataWindow;
+
+ PTBD pTBD;
+
+ UCHAR TmpUchar2;
+ UCHAR MapWindow;
+
+ USHORT TbdOffset;
+ USHORT BufferOffset;
+
+
+ SET_DATAWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ //
+ // Check to see if there are any free TBD descriptors. If not then
+ // we can't do any sends now
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&pSync->TbdIndex, &(pDataWindow->FreeTDBs.SRB_ReadPtr[0]));
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar2, &(pDataWindow->FreeTDBs.SRB_WritePtr[0]));
+
+ if (pSync->TbdIndex == TmpUchar2 ) {
+ SET_RECDWINDOW(pAdapter,INTERRUPT_ENABLED);
+ return FALSE;
+ }
+
+ //
+ // Get the address of the TBD in the NIU data segment
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&TbdOffset,
+ &(pDataWindow->FreeTDBs.SRB_Offsets[pSync->TbdIndex])
+ );
+
+ pTBD=(PTBD)((PUCHAR)pAdapter->pCardRam+TbdOffset);
+
+ //
+ // Set the length of the frame to be sent in the TBD
+ //
+
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pTBD->TBD_Frame_Length), (USHORT)pSync->PacketLength);
+ UBNEI_MOVE_USHORT_TO_SHARED_RAM(&(pTBD->TBD_EOF_and_Length), (USHORT)pSync->PacketLength | 0x8000);
+
+ //
+ // Get a pointer to the TBD buffer located in the NIU code segment
+ // Under the current version of download code the transmit buffer is
+ // is 1514 bytes long, so this makes things easy
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_USHORT(&BufferOffset, &(pTBD->TBD_Buffer_offset));
+
+ pSync->SendBuffer=(PUCHAR)pAdapter->pCardRam + BufferOffset;
+
+ //
+ // Set the map register to point to the correct window to access
+ // the send buffer
+ //
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&MapWindow, &(pTBD->TBD_Buffer_Map));
+
+ pAdapter->MapRegSync.NewMapRegister=MapWindow | INTERRUPT_ENABLED;
+
+ UbneiMapRegisterChangeSync(&pAdapter->MapRegSync);
+
+ return TRUE;
+
+}
+
+BOOLEAN
+UbneiGiveSendBufferToCardSync(
+ PSEND_SYNC_CONTEXT pSync
+ )
+
+{
+ PUBNEI_ADAPTER pAdapter=pSync->pAdapter;
+ PHIGHNIUDATA pDataWindow = (PHIGHNIUDATA) pAdapter->pDataWindow;
+
+ UCHAR TmpUchar1;
+
+
+ SET_DATAWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ //
+ // To actually give the data to the NIU to send, we remove the this
+ // TBD from the FreeTDB buffer and add it to XmtFrames buffer
+ //
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->FreeTDBs.SRB_ReadPtr[0]), pSync->TbdIndex + 1);
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&TmpUchar1, &(pDataWindow->XmtFrames.SRB_WritePtr[0]));
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pDataWindow->XmtFrames.SRB_WritePtr[0]), TmpUchar1 + 1);
+
+ SET_RECDWINDOW(pAdapter,INTERRUPT_ENABLED);
+
+ return TRUE;
+}
diff --git a/private/ntos/ndis/ubnei/sources b/private/ntos/ndis/ubnei/sources
new file mode 100644
index 000000000..c5932c81d
--- /dev/null
+++ b/private/ntos/ndis/ubnei/sources
@@ -0,0 +1,55 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl
+
+!ENDIF
+
+MAJORCOMP=ntos
+MINORCOMP=ndis
+
+TARGETNAME=ubnei
+TARGETPATH=\nt\public\sdk\lib
+TARGETTYPE=DRIVER
+
+TARGETLIBS=$(BASEDIR)\public\sdk\lib\*\ndis.lib
+C_DEFINES=$(C_DEFINES) -DNDIS_MINIPORT_DRIVER
+
+INCLUDES=..\..\inc;..\..\..\inc
+
+SOURCES= ubnei.rc \
+ initdata.c \
+ init.c\
+ ubnei.c\
+ interrup.c\
+ card.c\
+ request.c \
+ send.c\
+ receive.c\
+ config.c \
+ map.c
+
+
+RELATIVE_DEPTH=..\..
+
+MSC_WARNING_LEVEL=/W3 /WX
+
+NTTARGETFILES=ubnei.bin
+
diff --git a/private/ntos/ndis/ubnei/ubhard.h b/private/ntos/ndis/ubnei/ubhard.h
new file mode 100644
index 000000000..8823a6822
--- /dev/null
+++ b/private/ntos/ndis/ubnei/ubhard.h
@@ -0,0 +1,303 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ init.h
+
+Abstract:
+
+ This is the init header file for the Ungermann Bass Ethernet Controller.
+
+ This file contains definitions and macros used in initializing various
+ variables at driver entry (or init ) time.
+
+Author:
+
+ Sanjeev Katariya (sanjeevk) 03-05-92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's(dos)
+
+Revision History:
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+--*/
+
+
+#include "packon.h"
+
+
+
+//
+// ADAPTER TYPES
+//
+#define PCNIU 0
+#define COST_REDUCED_PCNIU 1
+#define NIUPC 2
+#define NIUPS 3
+#define GPCNIU 4 // Ungermann Bass NIUpc/EOTP
+#define PCNIUEX 5
+
+//
+// ADAPTER CLASSES
+//
+#define PHOENIX 0
+#define ATLANTA 1
+#define CHAMELEON 2
+
+
+//
+// BITS IN ADAPTER CONTROL PORT DATA
+//
+#define DO_PARITY_CHECK_BIT 4
+#define x12V_BIT 2
+#define LED_BIT 1
+
+//
+//
+//
+//#define INTERRUPT_CONTROL_BIT 0x2
+
+//
+// BITS IN ADAPTER FLAGS
+//
+#define TWO_PASS_DIAGNOSTICS 0x80
+#define USE_INTERFACE_PORT 0x40
+#define ASYNCHRONOUS_READY 0x20
+
+
+//
+// ADAPTER DESCRIPTIONS
+//
+#define PCNIU_DESCRIPTION "Ungermann-Bass Personal NIU"
+#define NIUPC_DESCRIPTION "Ungermann-Bass NIUpc"
+#define NIUPS_DESCRIPTION "Ungermann-Bass NIUps or NIUps/EOTP"
+#define GPCNIU_DESCRIPTION "Ungermann-Bass NIUpc/EOTP"
+#define PCNIUEX_DESCRIPTION "Ungermann-Bass Personal NIU/ex"
+
+
+
+
+// DEFAULT HARDWARE SETTINGS
+
+
+//
+// Default hardware settings for ANY Ungermann Bass card
+// supported by this driver
+//
+#define DEFAULT_IO_BASEADDRESS (UINT)0x368
+#define DEFAULT_ADAPTER_TYPE GPCNIU
+#define DEFAULT_INTERRUPT_NUMBER 5
+#define DEFAULT_MEMORY_WINDOW (UINT)0xD8000
+
+
+
+#define NIU_CONTROL_AREA_OFFSET (USHORT)0xFF00
+
+
+//
+// Default hardware settings for specific Ungermann Bass cards
+//
+
+
+//
+// GPCNIU CARD
+//
+
+//
+// Settings of I/O Base Address jumper on the NIUpc/EOTP card.
+// Choices are 0x300, 0x310, 0x330, 0x350, 0x250, 0x280, 0x2a0, and 0x2e0.
+//
+#define DEFAULT_GPCNIU_IO_BASEADDRESS (UINT)0x360
+
+//
+// Setting for the interrupt number the NIUpc/EOTP board is using.
+// Choices are 2, 3, 4, 5, 7 or 12.
+//
+#define DEFAULT_GPCNIU_INTERRUPT_NUMBER 3
+
+//
+// Shared memory setting for the NIUpc/EOTP adapter.
+// are 0xd8000,
+//
+#define DEFAULT_GPCNIU_MEMORY_WINDOW 0xD8000
+
+
+#define GPCNIU_MINIMUM_WINDOW_SIZE 0x4000
+#define GPCNIU_OPERATIONAL_CS 0x2000
+#define GPCNIU_PRIMARY_DS 0x3000
+#define GPCNIU_TX_BUFFER_SEGS 0x3000
+#define GPCNIU_HIGHEST_RAM_SEGS 0x7000
+#define GPCNIU_SCSP_SEGS 0x7000
+#define GPCNIU_POD_STATUS_ADDR 0xFF80
+#define GPCNIU_HOST_INTR_PORT 0x3000
+#define GPCNIU_82586_CA_PORT 0x0080
+#define GPCNIU_82586_RESET_PORT 0x0280
+#define GPCNIU_ADAPTER_CTRL_PORT 0x0200
+#define GPCNIU_IRQSEL_LEDPORT 0x0180
+#define GPCNIU_DEADMAN_TIMERPORT 0x1006
+#define GPCNIU_LEDOFF_12V_DOPARCHK x12V_BIT
+#define GPCNIU_LEDON_12V_DOPARCHK x12V_BIT+LED_BIT
+#define GPCNIU_ADAPTER_FLAGS TWO_PASS_DIAGNOSTICS+ASYNCHRONOUS_READY
+#define GPCNIU_ADAPTER_CODE 'G'
+#define NIUPS_ADAPTER_CODE 'Y'
+#define GPCNIU_CLI_OFFSET 0x0
+#define GPCNIU_MAP_OFFSET 0x0
+#define GPCNIU_INTR_STATUS_OFFSET 0x1
+#define GPCNIU_SETWINBASE_OFFSET 0x2
+
+#define GPCNIU_NEXT_RAM_PAGE ((UCHAR)(WINDOWSIZE >> 8*3))
+
+
+
+#define NIUPC_MINIMUM_WINDOW_SIZE 0x8000
+#define NIUPC_OPERATIONAL_CS 0x2000
+#define NIUPC_PRIMARY_DS 0x3000
+#define NIUPC_TX_BUFFER_SEGS 0x3000
+#define NIUPC_HIGHEST_RAM_SEGS 0x3000
+#define NIUPC_SCSP_SEGS 0x3000
+#define NIUPC_POD_STATUS_ADDR 0xFEF8
+#define NIUPC_HOST_INTR_PORT 0x0100
+#define NIUPC_82586_CA_PORT 0x0080
+#define NIUPC_82586_RESET_PORT 0x0280
+#define NIUPC_ADAPTER_CTRL_PORT 0x0200
+#define NIUPC_IRQSEL_LEDPORT 0x0000
+#define NIUPC_DEADMAN_TIMERPORT 0x0018
+#define NIUPC_LEDOFF_12V_DOPARCHK x12V_BIT+DO_PARITY_CHECK_BIT+LED_BIT
+#define NIUPC_LEDON_12V_DOPARCHK x12V_BIT+DO_PARITY_CHECK_BIT
+#define NIUPC_ADAPTER_FLAGS 0
+#define NIUPC_ADAPTER_CODE 'V'
+#define NIUPC_CLI_OFFSET 0x0
+#define NIUPC_MAP_OFFSET 0x0
+#define NIUPC_INTR_STATUS_OFFSET 0x0
+#define NIUPC_SETWINBASE_OFFSET 0x0
+
+
+
+
+
+// DEFAULT HARDWARE SETTINGS:END
+
+
+
+//
+// The NIU control area in the InitWindowPage.
+// Starts at offset:
+//
+// (MemMapped)SharedMemBase + NIU_CONTROL_AREA_OFFSET(0xFF00)
+//
+
+
+
+typedef struct _NIUDETAILS {
+ UCHAR MappingTable[0x20];
+ USHORT AdapterClass;
+ USHORT MinimumWindowSize;
+ USHORT OperationalCodeSegment;
+ USHORT PrimaryDataSegment;
+ USHORT TransmitBufferSegment;
+ USHORT HighestRamSegment;
+ USHORT SCPSegment;
+ USHORT POD_Status_Address;
+ USHORT HostInterruptPort;
+ USHORT _82586_CA_Port;
+ USHORT _82586_RESET_Port;
+ USHORT AdapterControlPort;
+ UCHAR LED_Off_12Volts_DoParityCheck;
+ UCHAR LED_On_12Volts_DoParityCheck;
+ USHORT IRQ_Select_And_LED_Port;
+ USHORT DeadManTimerPort;
+ UCHAR IO_PortOffset[4];
+ UCHAR AdapterFlags;
+ UCHAR AdapterCode;
+ } NIUDETAILS, *PNIUDETAILS;
+
+
+
+
+
+
+
+typedef struct tagOtherRingBufferDesc {
+ UCHAR ORB_WritePtr_Byte;
+ UCHAR res1;
+ UCHAR ORB_ReadPtr_Byte;
+ UCHAR res2;
+ UCHAR ORB_PtrLimit;
+ UCHAR ORB_ElementSize;
+ USHORT ORB_BufferBase;
+ USHORT ORB_Windowed_BufferBase;
+ UCHAR ORB_ObjectMap;
+ UCHAR ORB_pad[5];
+ } ORB, *PORB;
+
+
+typedef struct tagRequest_RingBuffer_Entry {
+ USHORT RequestCode;
+ USHORT RequestID;
+ USHORT RequestParam1;
+ UCHAR RequestData[6];
+ } RRBE, *PRRBE;
+
+typedef struct tagResult_RingBuffer_Entry {
+ USHORT ResultID;
+ USHORT ResultCode;
+ } RESULTRBE, *PRESULTRBE;
+
+
+typedef struct tagTBD {
+ USHORT TBD_EOF_and_Length;
+ USHORT TBD_next_TBD;
+ USHORT TBD_Buffer;
+ UCHAR TBD_Buffer_MSB;
+ UCHAR TBD_Buffer_Map;
+ USHORT TBD_Frame_Length;
+ UCHAR TBD_Unused;
+ UCHAR TBD_Flags;
+ USHORT TBD_next_TDB_offset;
+ USHORT TBD_Buffer_offset;
+ } TBD, *PTBD;
+
+typedef struct tagRBD {
+ USHORT RBD_EOF_F_and_Length;
+ USHORT RBD_next_RBD;
+ USHORT RBD_Buffer;
+ UCHAR RBD_Buffer_MSB;
+ UCHAR RBD_Owner;
+ USHORT RBD_EOL_and_Size;
+ USHORT RBD_Buffer_Segment;
+ USHORT RBD_Frame_Length;
+ UCHAR RBD_Flags;
+ UCHAR RBD_unused;
+ } RBD, *PRBD;
+
+
+typedef struct tagMCB {
+ UCHAR res;
+ UCHAR MCB_Status;
+ USHORT MCB_Command;
+ USHORT next_CB;
+ USHORT MCB_Count;
+ } MCB, *PMCB;
+
+
+
+
+// SYSTEM mode Bits
+
+#define BROADBAND_MODE 0x8000
+#define INTERNAL_READY_SYNC 0x4000
+
+
+// System_State bits
+
+#define INITIALIZED 0x8000
+
+
+#include "packoff.h"
diff --git a/private/ntos/ndis/ubnei/ubnei.bin b/private/ntos/ndis/ubnei/ubnei.bin
new file mode 100644
index 000000000..f70090471
--- /dev/null
+++ b/private/ntos/ndis/ubnei/ubnei.bin
Binary files differ
diff --git a/private/ntos/ndis/ubnei/ubnei.c b/private/ntos/ndis/ubnei/ubnei.c
new file mode 100644
index 000000000..9d489f4a1
--- /dev/null
+++ b/private/ntos/ndis/ubnei/ubnei.c
@@ -0,0 +1,567 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ macndis.c
+
+Abstract:
+
+ This is the mac ndis file for the Ungermann Bass Ethernet Controller.
+ This driver conforms to the NDIS 3.0 interface.
+
+
+ This driver currently supports three UB Network cards.
+
+ NIUpc -- Old 16-bit long cards
+ 256k of on board memory
+ jumpers to set i/o base, memory window, interrupt level
+ Memory window size is 32k
+
+ NIUpc/EOTP -- New short 16-bit cards
+ 512k of memory
+ i/o base set by jumpers
+ Interrupt level, memory window base and size software
+ configurable
+ Memory window size is 16k, 32k
+
+ NIUps -- Basically an MCA EOTP card.
+ 512k of memory
+ i/o base, interrupt level, memory window determined
+ by MCA POS mechanism
+ Memory window size is 16k, 32k, 64k
+
+ All of the UB card are composed of an 80186 and an Intel 82586 lan
+ coprocessor.
+
+ The Download code that is copied to the card and run is a slightly
+ modified version of the down load code from UB NDIS 2.01 driver.
+
+ This download load code was basically designed to the least common
+ denominator of there older net cards. It only makes use of 128k
+ of the cards memory no matter what type of card.
+
+ The card memory is laided out as a 64k data segment and 64k code segment
+ The data segment is further divided into to parts. The lower 32k
+ of the data segment holds all of the receive buffers and receive buffer
+ descriptors. It also holds various statistics for ease of access.
+ The upper 32k is used to store various items of which the ring buffers
+ are of primary interest. If the Memory window size is 16k then only
+ the first 16k of both 32k halfs is used.
+
+ The code segment holds the all of the download code. The remainder of
+ the 64k (~48k) is used for the transmit buffers.
+
+ The i/o register of most interest is the map register. This register
+ is at offset 0 from the I/O base. The register has three functions.
+ 1) The upper 6 bits of this register determines which section
+ of the cards memory is currently viewable in the memory window.
+
+ 2) Bit #1 is used to enable and disable interrupts from the card.
+ This bit is also used to clear and interrupt from the card.
+ In order to clear and interrupt, the bit must be set to zero and
+ the set 1. This little fact is what makes things interresting
+ in handling interrupts. To dismiss the interrupt you must write
+ some value to this port, But this port also controls the window
+ map so you need to be careful about just what you write to this
+ port. On the old 16-bit card this port is not readable.
+ Obviously bad things would happen on an MP if one processor
+ set the map to one thing and second came along and set it to
+ something else. Spin locks will work to protect the port
+ for normal accesses, but they can not be used to protect it from
+ access from the ISR which must clear the interrupt.
+
+ I had originally planned to not do anything in the ISR and let
+ the DPC handle clearing the interrupt. This works fine on
+ the NON-MCA cards, but this one is LEVEL TRIGGERED so I need
+ to clear the interrupt by writing something to the port in the ISR.
+
+ The way I have currently implemented this is to only have the
+ reeceive window mapped in when interrupts are enabled. I do this
+ by disabling interrupts from the card and clearing the interrupt
+ in the ISR and returning. Now when the DPC runs it knows that
+ interrutps are disabled, and can change the map port as it wishes.
+ The code call by protocols to handle request does not ever
+ access any thing that is not in the receive page.
+
+ 3) Bit #0 is used to reset the card. Setting this bit resets the card.
+ This bit reamins 0 except during init.
+
+
+
+
+
+
+
+
+
+
+
+Author:
+
+ Sanjeev Katariya (sanjeevk) 03-05-92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's(dos)
+
+Revision History:
+
+ Brian Lieuallen BrianLie 07/21/92
+ Made it work.
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+--*/
+
+
+
+#include <ndis.h>
+#include <efilter.h>
+
+#include "niudata.h"
+#include "debug.h"
+
+#include "ubhard.h"
+#include "ubsoft.h"
+#include "ubnei.h"
+
+#include "map.h"
+
+//
+// This constant is used for places where NdisAllocateMemory
+// needs to be called and the HighestAcceptableAddress does
+// not matter.
+//
+
+NDIS_PHYSICAL_ADDRESS HighestAcceptableMax =
+ NDIS_PHYSICAL_ADDRESS_CONST(-1,-1);
+
+
+
+
+
+NDIS_STATUS
+UbneiAddressChangeAction(
+ IN UINT NewFilterCount,
+ IN PUCHAR NewAddresses,
+ IN NDIS_HANDLE MacBindingHandle
+ )
+
+/*++
+
+Routine Description:
+
+ Action routine that will get called when a particular filter
+ class is first used or last cleared.
+
+ NOTE: This routine assumes that it is called with the lock
+ acquired.
+
+Arguments:
+
+
+ NewFilterCount - The number of addresses that should now be on the card.
+
+ NewAddresses - A list of addresses that should be put on the card.
+
+ MacBindingHandle - The context value returned by the MAC when the
+ adapter was opened. In reality, it is a pointer to ELNKII_OPEN.
+
+
+Return Value:
+
+ None.
+
+
+--*/
+
+{
+ PUBNEI_ADAPTER pAdapt = MacBindingHandle;
+
+
+ //
+ // Holds the status that should be returned to the filtering package.
+ //
+ NDIS_STATUS StatusOfAdd;
+ IF_REQ_LOUD(DbgPrint("UBNEI: AddressChangeAction called\n");)
+
+
+ if (NIU_SET_MULTICAST_LIST(pAdapt,
+ ChangeAddressDPC,
+ (PUCHAR)NewAddresses,
+ (USHORT)NewFilterCount
+ )) {
+
+ StatusOfAdd=NDIS_STATUS_PENDING;
+ } else {
+ //
+ // The adapter has failed, It doesn't really matter
+ // what we return since the card has stopped working
+ //
+ StatusOfAdd=NDIS_STATUS_FAILURE;
+ }
+
+
+
+ return StatusOfAdd;
+
+}
+
+
+
+VOID
+ChangeAddressDPC(
+ IN NDIS_STATUS Status,
+ IN PVOID Context
+ )
+/*++
+
+Routine Description:
+
+ This routine is called when the NIU completes a multicast or filter
+ change request. It in turn completes the pended request from the protocol
+
+Arguments:
+
+ Context is actually a pointer to the an NDIS_REQUEST
+
+
+--*/
+
+{
+ PUBNEI_ADAPTER pAdapter=Context;
+
+ IF_REQ_LOUD (DbgPrint("FilterActionDPC called\n");)
+
+ NdisMSetInformationComplete(
+ pAdapter->NdisAdapterHandle,
+ Status
+ );
+
+
+
+}
+
+
+
+
+VOID
+DummyDPC(
+ IN NDIS_STATUS status,
+ IN PVOID pContext
+ )
+/*++
+
+Routine Description:
+
+ This routine is called when the NIU completes a request and nothing
+ needs to be completed to a protocol. This routine is passed as the
+ callback address passed to filter functions during a close and also
+ used during a Reset which is restarting the adapter.
+
+Arguments:
+
+
+
+--*/
+
+{
+ IF_REQ_LOUD (DbgPrint("UBNEI: DummyDPC called for filter action routine called at close\n");)
+ return;
+
+}
+
+
+
+
+
+
+NDIS_STATUS
+UbneiFilterChangeAction(
+ IN UINT NewFilterClasses,
+ IN NDIS_HANDLE MacBindingHandle
+ )
+
+
+/*++
+
+Routine Description:
+
+ Action routine that will get called when an address is added to
+ the filter that wasn't referenced by any other open binding.
+
+ NOTE: This routine assumes that it is called with the lock
+ acquired.
+
+Arguments:
+
+ OldFilterClasses - A bit mask that is currently on the card telling
+ which packet types to accept.
+
+ NewFilterClasses - A bit mask that should be put on the card telling
+ which packet types to accept.
+
+ MacBindingHandle - The context value returned by the MAC when the
+ adapter was opened. In reality, it is a pointer to ELNKII_OPEN.
+
+ NdisRequest - The NDIS_REQUEST which submitted the filter change command.
+
+ Set - A flag telling if the command is a result of a close or not.
+
+Return Value:
+
+ Status of the change (successful or pending).
+
+
+--*/
+
+{
+ PUBNEI_ADAPTER pAdapt = MacBindingHandle;
+ USHORT NewFilter=0;
+
+ //
+ // Holds the status that should be returned to the filtering package.
+ //
+ NDIS_STATUS StatusOfAdd;
+ IF_REQ_LOUD(DbgPrint("UBNEI: FilterChangeAction called\n");)
+
+ if (NewFilterClasses & ~(NDIS_PACKET_TYPE_DIRECTED |
+ NDIS_PACKET_TYPE_MULTICAST |
+ NDIS_PACKET_TYPE_ALL_MULTICAST |
+ NDIS_PACKET_TYPE_BROADCAST |
+ NDIS_PACKET_TYPE_PROMISCUOUS )) {
+
+ IF_REQ_LOUD(DbgPrint("UBNEI: Stupid protocol set bogus filter\n");)
+ return NDIS_STATUS_NOT_SUPPORTED;
+ }
+
+
+ if (NewFilterClasses & ( NDIS_PACKET_TYPE_DIRECTED |
+ NDIS_PACKET_TYPE_MULTICAST
+ )) {
+
+ NewFilter|=0x0001;
+ }
+
+ if (NewFilterClasses & NDIS_PACKET_TYPE_BROADCAST) {
+ NewFilter|=0x0002;
+ }
+
+ //
+ // 82586 does not support all multicast so we set to promiscuous
+ //
+
+ if (NewFilterClasses & NDIS_PACKET_TYPE_ALL_MULTICAST) {
+ NewFilter|=0x0007;
+ }
+
+ if (NewFilterClasses & NDIS_PACKET_TYPE_PROMISCUOUS) {
+ NewFilter|=0x0007;
+ }
+
+
+
+ pAdapt->PacketFilter=NewFilter;
+
+
+ if (NIU_SET_FILTER(pAdapt,
+ ChangeAddressDPC,
+ NewFilter)) {
+
+
+ StatusOfAdd=NDIS_STATUS_PENDING;
+ } else {
+ //
+ // The adapter has failed, It doesn't really matter
+ // what we return since the card has stopped working
+ //
+ StatusOfAdd=NDIS_STATUS_FAILURE;
+ }
+
+
+
+ return StatusOfAdd;
+
+}
+
+
+
+
+
+
+
+
+BOOLEAN
+UbneiCheckForHang(
+ IN NDIS_HANDLE Context
+ )
+/*++
+
+Routine Description:
+
+
+Arguments:
+
+ DeferredContext - will be a pointer to the adapter block
+
+Return Value:
+
+ None.
+
+--*/
+
+{
+ PUBNEI_ADAPTER pAdapter = ((PUBNEI_ADAPTER)Context);
+
+ PLOWNIUDATA pRcvDWindow = (PLOWNIUDATA) pAdapter->pCardRam;
+
+ UCHAR InterruptActive;
+
+
+// IF_LOG('w');
+
+ if (!pAdapter->WaitingForDPC) {
+ //
+ // We are not waiting on a DPC
+ //
+ ASSERT_RECEIVE_WINDOW( pAdapter);
+
+ UBNEI_MOVE_SHARED_RAM_TO_UCHAR(&InterruptActive,&(pRcvDWindow->InterruptActive));
+
+ if (InterruptActive != 0) {
+ //
+ // The card has generated an interrupt
+ //
+ if (pAdapter->WakeUpState==0) {
+ //
+ // This is first time here
+ //
+ pAdapter->DpcHasRun=FALSE;
+
+ pAdapter->WakeUpState=1;
+
+ } else {
+ //
+ // This is the second time in here, check to see if the DPC ran
+ //
+ if (pAdapter->DpcHasRun) {
+ //
+ // The dpc has run so things must be ok
+ //
+ pAdapter->WakeUpState=0;
+
+ } else {
+ //
+ // The dpc has not run, ask the card to do it again.
+ //
+ IF_LOUD(DbgPrint("UBNEI: CheckForHang: Lost an interrupt?!?\n");)
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pRcvDWindow->InterruptActive), 0x0);
+
+ UBNEI_MOVE_UCHAR_TO_SHARED_RAM(&(pRcvDWindow->HostWantsInterrupt), 0xFF);
+
+ pAdapter->WakeUpState=0;
+
+ }
+
+ }
+
+ } else {
+ //
+ // The has not generated an interrupt
+ //
+ pAdapter->WakeUpState=0;
+ }
+
+ } else {
+ //
+ // A dpc is pending
+ //
+ }
+
+
+ return FALSE;
+
+
+
+}
+
+
+
+
+NDIS_STATUS
+UbneiReset(
+ OUT PBOOLEAN AddressResetting,
+ IN NDIS_HANDLE MacBindingHandle
+ )
+
+/*++
+
+Routine Description:
+
+ NDIS function.
+
+Arguments:
+
+ See NDIS 3.0 spec.
+
+--*/
+
+{
+ PUBNEI_ADAPTER pAdapter = ((PUBNEI_ADAPTER)MacBindingHandle);
+
+ IF_INIT_LOUD(DbgPrint("UbneiReset() Called\n");)
+
+ NIU_RESET_ADAPTER(
+ pAdapter,
+ ResetAdapterDPC
+ );
+
+ *AddressResetting=FALSE;
+
+ return NDIS_STATUS_PENDING;
+
+
+}
+
+
+
+
+
+VOID
+ResetAdapterDPC(
+ IN NDIS_STATUS status,
+ IN PVOID Context
+ )
+/*++
+
+Routine Description:
+
+ This routine is called when the NIU completes a request and nothing
+ needs to be completed to a protocol. This routine is passed as the
+ callback address passed to filter functions during a close and also
+ used during a Reset which is restarting the adapter.
+
+Arguments:
+
+
+
+--*/
+
+{
+ PUBNEI_ADAPTER pAdapter = ((PUBNEI_ADAPTER)Context);
+
+ IF_INIT_LOUD (DbgPrint("Ubnei: ResetAdapterDpc\n");)
+
+ NdisMResetComplete(
+ pAdapter->NdisAdapterHandle,
+ NDIS_STATUS_SUCCESS,
+ FALSE
+ );
+
+ return;
+
+}
diff --git a/private/ntos/ndis/ubnei/ubnei.h b/private/ntos/ndis/ubnei/ubnei.h
new file mode 100644
index 000000000..d2799faeb
--- /dev/null
+++ b/private/ntos/ndis/ubnei/ubnei.h
@@ -0,0 +1,332 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ ndis.h
+
+Abstract:
+
+ This is the ndis header file for the Ungermann Bass Ethernet Controller.
+
+ It contains the various definitions, macros and function declarations
+ of the NDIS3.0 specification implemented in the Ungermann Bass Ethernet
+ Controller.
+
+Author:
+
+ Sanjeev Katariya (sanjeevk) 03-05-92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's
+
+Revision History:
+
+ Brian Lieuallen BrianLie 07/21/92
+ Made it work.
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+
+
+--*/
+
+
+
+
+
+#define STATIC static
+
+
+//
+// This constant is used for places where NdisAllocateMemory
+// needs to be called and the HighestAcceptableAddress does
+// not matter.
+//
+
+extern NDIS_PHYSICAL_ADDRESS HighestAcceptableMax;
+
+//
+// NDIS 3.0 entry functions
+//
+
+
+
+VOID
+UbneiAdjustMaxLookAhead(
+ IN PUBNEI_ADAPTER pAdapter
+ );
+
+
+
+
+BOOLEAN
+Ubnei_InterruptServiceRoutine(
+ IN PVOID DefferedContext
+ );
+
+BOOLEAN
+UbneiSetInitInterruptSync(
+ PVOID Context
+ );
+
+BOOLEAN
+UbneiSetNormalInterruptSync(
+ PVOID Context
+ );
+
+
+//
+// Contained in CARD.C
+//
+
+BOOLEAN
+CardTest (
+ OUT PUBNEI_ADAPTER pAdapter
+ );
+
+BOOLEAN
+CardSetup (
+ OUT PUBNEI_ADAPTER pAdapter
+ );
+
+
+BOOLEAN
+CardStartNIU(
+ OUT PUBNEI_ADAPTER pNewAdapt
+ );
+
+BOOLEAN
+NIU_General_Request3(
+ IN NIU_GEN_REQ_DPC pDPCCallback,
+ IN PVOID pContext,
+ IN USHORT RequestCode,
+ IN USHORT param1,
+ IN PUCHAR param2
+ );
+
+
+
+
+VOID
+NIU_General_Req_Result_Hand(
+ IN PUBNEI_ADAPTER pAdapt
+ );
+
+VOID
+NIU_Send_Request_To_Card(
+ IN PUBNEI_ADAPTER pAdapt
+ );
+
+VOID
+NIU_Abort_General_Req(
+ IN PUBNEI_ADAPTER pAdapter
+ );
+
+
+
+VOID
+OpenAdapterDPC(
+ IN NDIS_STATUS status,
+ IN PVOID pContext
+ );
+
+VOID
+ChangeAddressDPC(
+ IN NDIS_STATUS status,
+ IN PVOID pContext
+ );
+
+VOID
+ResetAdapterDPC(
+ IN NDIS_STATUS status,
+ IN PVOID pContext
+ );
+
+VOID
+DummyDPC(
+ IN NDIS_STATUS status,
+ IN PVOID pContext
+ );
+
+VOID
+CloseAdapterDPC(
+ IN NDIS_STATUS status,
+ IN PVOID pContext
+ );
+
+
+
+
+//
+// Contained in send.c
+//
+
+VOID
+CheckForSends(
+ PUBNEI_ADAPTER pAdapt
+ );
+
+
+//
+// Contained in receive.c
+//
+
+BOOLEAN
+CheckForReceives(
+ IN PUBNEI_ADAPTER pAdapter
+ );
+
+
+
+//
+// Contained in registry.c
+//
+
+NDIS_STATUS
+UbneiReadRegistry(
+ IN PUBNEI_ADAPTER pAdapter,
+ IN NDIS_HANDLE ConfigurationHandle
+ );
+
+
+
+
+
+
+
+
+
+
+BOOLEAN
+UbneiCheckForHang(
+ IN NDIS_HANDLE MiniportAdapterContext
+ );
+
+
+
+NDIS_STATUS
+UbneiQueryInformation(
+ IN NDIS_HANDLE MiniportContext,
+ IN NDIS_OID Oid,
+ IN PVOID InfoBuffer,
+ IN ULONG BytesLeft,
+ OUT PULONG BytesNeeded,
+ OUT PULONG BytesWritten
+ );
+
+
+
+NDIS_STATUS
+UbneiSetInformation(
+ IN NDIS_HANDLE MiniportAdapterContext,
+ IN NDIS_OID Oid,
+ IN PVOID InformationBuffer,
+ IN ULONG InformationBufferLength,
+ OUT PULONG BytesRead,
+ OUT PULONG BytesNeeded
+ );
+
+NDIS_STATUS
+UbneiInitialize(
+ OUT PNDIS_STATUS OpenErrorStatus,
+ OUT PUINT SelectedMediumIndex,
+ IN PNDIS_MEDIUM MediumArray,
+ IN UINT MediumArraySize,
+ IN NDIS_HANDLE MiniportAdapterHandle,
+ IN NDIS_HANDLE WrapperConfigurationContext
+ );
+
+VOID
+UbneiHalt(
+ IN NDIS_HANDLE MiniportAdapterContext
+ );
+
+
+NDIS_STATUS
+UbneiReset(
+ OUT PBOOLEAN AddressResetting,
+ IN NDIS_HANDLE MacBindingHandle
+ );
+
+NDIS_STATUS
+UbneiMacSend(
+ IN NDIS_HANDLE MacBindingHandle,
+ IN PNDIS_PACKET pPacket,
+ IN UINT Flags
+ );
+
+NDIS_STATUS
+UbneiTransferData(
+ OUT PNDIS_PACKET Packet,
+ OUT PUINT BytesTransferred,
+ IN NDIS_HANDLE MacBindingHandle,
+ IN NDIS_HANDLE MacReceiveContext,
+ IN UINT ByteOffset,
+ IN UINT BytesToTransfer
+ );
+
+
+NDIS_STATUS
+UbneiReconfigure(
+ OUT PNDIS_STATUS OpenErrorStatus,
+ IN NDIS_HANDLE MiniportAdapterContext,
+ IN NDIS_HANDLE ConfigurationHanel
+ );
+
+
+
+
+VOID
+UbneiIsr(
+ OUT PBOOLEAN InterruptRecognized,
+ OUT PBOOLEAN QueueDpc,
+ IN NDIS_HANDLE Context
+ );
+
+
+
+VOID
+UbneiIsrDpc(
+ IN NDIS_HANDLE DeferredContext // will be a pointer to the adapter block
+ );
+
+
+
+VOID
+UbneiEnableInterrupts(
+ IN NDIS_HANDLE Context
+ );
+
+
+VOID
+UbneiDisableInterrupts(
+ IN NDIS_HANDLE Context
+ );
+
+
+
+
+VOID
+UbneiMapRegisterChangeSync(
+ PSYNC_CONTEXT Context
+ );
+
+
+
+NDIS_STATUS
+UbneiAddressChangeAction(
+ IN UINT NewFilterCount,
+ IN PUCHAR NewAddresses,
+ IN NDIS_HANDLE MacBindingHandle
+ );
+
+
+NDIS_STATUS
+UbneiFilterChangeAction(
+ IN UINT NewFilterClasses,
+ IN NDIS_HANDLE MacBindingHandle
+ );
diff --git a/private/ntos/ndis/ubnei/ubnei.rc b/private/ntos/ndis/ubnei/ubnei.rc
new file mode 100644
index 000000000..545f76cd3
--- /dev/null
+++ b/private/ntos/ndis/ubnei/ubnei.rc
@@ -0,0 +1,12 @@
+#include <windows.h>
+
+#include <ntverp.h>
+
+#define VER_FILETYPE VFT_DRV
+#define VER_FILESUBTYPE VFT2_DRV_NETWORK
+#define VER_FILEDESCRIPTION_STR "Ungerman-Bass network driver"
+#define VER_INTERNALNAME_STR "UBNEI.SYS"
+#define VER_ORIGINALFILENAME_STR "UBNEI.SYS"
+
+#include "common.ver"
+
diff --git a/private/ntos/ndis/ubnei/ubsoft.h b/private/ntos/ndis/ubnei/ubsoft.h
new file mode 100644
index 000000000..90ac2240d
--- /dev/null
+++ b/private/ntos/ndis/ubnei/ubsoft.h
@@ -0,0 +1,381 @@
+/*++
+
+Copyright (c) 1990 Microsoft Corporation
+
+Module Name:
+
+ software.h
+
+Abstract:
+
+ This is the software definitions header file for the Ungermann Bass
+ Ethernet Controller.
+
+ This file contains definitions and macros used in
+
+Author:
+
+ Sanjeev Katariya (sanjeevk) 03-05-92
+
+Environment:
+
+ Kernel Mode Operating Systems : NT and other lesser OS's(dos)
+
+Revision History:
+
+ Brian Lieuallen BrianLie 12/15/93
+ Made it a mini-port
+
+--*/
+
+
+
+
+
+// DEFINES
+
+//
+// Default software settings for ANY Ungermann Bass card
+// supported by this driver
+//
+
+#define DEFAULT_MULTICAST_SIZE 16
+#define DEFAULT_MAXIMUM_REQUESTS 4
+#define DEFAULT_MAXIMUM_TRANSMITS 6
+#define DEFAULT_RECEIVE_BUFFER_SIZE 512
+#define DEFAULT_RECEIVE_BUFFERS 64
+
+
+#define UBNEI_NDIS_MAJOR_VERSION 3
+#define UBNEI_NDIS_MINOR_VERSION 0
+
+
+#define UBNEI_ETHERNET_HEADER_SIZE 14
+
+//
+// Default software settings for specific Ungermann Bass cards
+//
+//#define DEFAULT_GPCNIU_MAXMCAST_SIZE 16
+
+
+
+
+
+#define UBNEI_MOVE_MEM(dest,src,size) NdisMoveMemory(dest,src,size)
+
+#define UBNEI_MOVE_SHARED_RAM_TO_MEM(dest,src,size) NdisMoveFromMappedMemory(dest,src,size)
+#define UBNEI_MOVE_MEM_TO_SHARED_RAM(dest,src,size) NdisMoveToMappedMemory(dest,src,size)
+
+#define UBNEI_MOVE_UCHAR_TO_SHARED_RAM(dest, src) NdisWriteRegisterUchar((PUCHAR)dest, (UCHAR)(src))
+//#define UBNEI_MOVE_USHORT_TO_SHARED_RAM(dest, src) NdisWriteRegisterUshort((PUSHORT)dest, (USHORT)(src))
+//#define UBNEI_MOVE_DWORD_TO_SHARED_RAM(dest, src) NdisWriteRegisterUlong((PULONG)dest, (ULONG)(src))
+
+#define UBNEI_MOVE_SHARED_RAM_TO_UCHAR(dest, src) NdisReadRegisterUchar((PUCHAR)src, (PUCHAR)(dest))
+#define UBNEI_MOVE_SHARED_RAM_TO_USHORT(dest, src) NdisReadRegisterUshort((PUSHORT)src, (PUSHORT)(dest))
+#define UBNEI_MOVE_SHARED_RAM_TO_DWORD(dest, src) NdisReadRegisterUlong((PULONG)src, (PULONG)(dest))
+
+
+
+
+#if 0
+
+#define UBNEI_MOVE_USHORT_TO_SHARED_RAM(dest, src) { \
+ \
+ if ((ULONG)(dest) & 1) { \
+ DbgPrint("UBNEI: Unaligned word write to shared ram %08x\n",dest); \
+ DbgBreakPoint(); \
+ } \
+ NdisWriteRegisterUshort((PUSHORT)(dest), (USHORT)(src)); \
+}
+
+#define UBNEI_MOVE_DWORD_TO_SHARED_RAM(dest, src) { \
+ \
+ if ((ULONG)(dest) & 3) { \
+ DbgPrint("UBNEI: Unaligned dword write to shared ram %08x\n",dest); \
+ DbgBreakPoint(); \
+ } \
+ \
+ NdisWriteRegisterUlong((PULONG)(dest), (ULONG)(src)); \
+}
+
+#else
+
+#define UBNEI_MOVE_USHORT_TO_SHARED_RAM(dest, src) NdisWriteRegisterUshort((PUSHORT)dest, (USHORT)(src))
+#define UBNEI_MOVE_DWORD_TO_SHARED_RAM(dest, src) NdisWriteRegisterUlong((PULONG)dest, (ULONG)(src))
+
+#endif
+
+
+//
+// Macros
+//
+#define MACRO_ASSERTALL() { \
+ ASSERT ( sizeof(CHAR) = 1 ); \
+ ASSERT ( sizeof(UCHAR) = 1 ); \
+ ASSERT ( sizeof(USHORT) = 2 ); \
+ ASSERT ( sizeof(UINT) = 4 ); \
+ ASSERT ( sizeof(ULONG) = 4 ); \
+ }
+
+
+
+typedef struct _PACKET_QUEUE {
+ PNDIS_PACKET QIn;
+ PNDIS_PACKET QOut;
+ } PACKET_QUEUE, *PPACKET_QUEUE;
+
+
+
+
+typedef struct _SYNC_CONTEXT {
+ struct _UBNEI_ADAPTER * pAdapter;
+ UCHAR CurrentMapRegister;
+ UCHAR NewMapRegister;
+ } SYNC_CONTEXT, * PSYNC_CONTEXT;
+
+typedef struct _SEND_SYNC_CONTEXT {
+ struct _UBNEI_ADAPTER * pAdapter;
+ PVOID SendBuffer;
+ UINT PacketLength;
+ UCHAR TbdIndex;
+ } SEND_SYNC_CONTEXT, *PSEND_SYNC_CONTEXT;
+
+typedef
+VOID
+(*NIU_GEN_REQ_DPC)(
+ IN NDIS_STATUS status,
+ IN PVOID pContext
+ );
+
+typedef struct _NIUREQUEST {
+ PVOID pContext;
+ NIU_GEN_REQ_DPC pDPCFunc;
+ PUCHAR AddressList;
+ UINT ListSize;
+ RRBE rrbe;
+ } NIUREQUEST, *PNIUREQUEST;
+
+
+
+//
+// One of these structures per adapter registered.
+//
+
+
+typedef struct _UBNEI_ADAPTER {
+
+ SYNC_CONTEXT MapRegSync;
+
+ //
+ // Window mapping values used to map in various pages
+ //
+
+ UCHAR InitWindow_Page;
+ UCHAR ReceiveDataWindow_Page;
+ UCHAR DataWindow_Page;
+ UCHAR CodeWindow_Page;
+
+
+ //
+ // Ports
+ //
+ PVOID InterruptMaskPort;
+ PVOID MapPort;
+ PVOID InterruptStatusPort;
+ PVOID SetWindowBasePort;
+
+
+ //
+ // NDIS wrapper information.
+ //
+
+ NDIS_HANDLE NdisAdapterHandle; // returned from NdisRegisterAdapter
+
+
+
+ //
+ // NDIS Interrupt information
+ //
+ NDIS_MINIPORT_INTERRUPT NdisInterrupt;
+ NDIS_INTERRUPT_MODE InterruptMode;
+ volatile UINT uInterruptCount;
+ BOOLEAN InInit;
+
+ volatile BOOLEAN WaitingForDPC;
+ BOOLEAN DpcHasRun;
+
+ BOOLEAN WaitingForXmitInterrupt;
+
+ //
+ // Registry information
+ //
+
+ PVOID TranslatedIoBase;
+
+ UINT IoPortBaseAddr;
+ UINT MemBaseAddr;
+ UINT MaxMultiCastTableSize;
+ UINT MaxRequests;
+ UINT MaxTransmits;
+ UINT ReceiveBuffers;
+ UINT ReceiveBufSize;
+ UINT AdapterType;
+ BOOLEAN Diagnostics;
+ CHAR IrqLevel;
+ ULONG WindowSize;
+ ULONG WindowMask;
+ ULONG NotWindowMask;
+
+
+ UCHAR StationAddress[ETH_LENGTH_OF_ADDRESS]; // filled in at init time
+ UCHAR PermanentAddress[ETH_LENGTH_OF_ADDRESS]; // filled in at init time
+
+ //
+ // Statistics used by Set/QueryInformation.
+ //
+
+ UINT TransmitBufferSpace;
+ UINT ReceiveBufferSpace;
+ UINT TransmitBlockSize;
+ UINT ReceiveBlockSize;
+
+
+ ULONG FramesXmitGood; // Good Frames Transmitted
+ ULONG FramesRcvGood; // Good Frames Received
+ ULONG FramesXmitBad; // Bad Frames Transmitted
+ ULONG FramesXmitOneCollision; // Frames Transmitted with one collision
+ ULONG FramesXmitManyCollisions; // Frames Transmitted with > 1 collision
+ ULONG FrameAlignmentErrors; // FAE errors counted
+ ULONG CrcErrors; // CRC errors counted
+ ULONG MissedPackets; // missed packet counted
+
+
+ //
+ // Look Ahead information.
+ //
+
+ ULONG MaxLookAhead;
+
+
+
+ //
+ // Adapter specific Infomation
+ //
+
+ USHORT PacketFilter;
+
+
+
+ //
+ // Timer functions/objects
+ //
+ UINT WakeUpState;
+
+ //
+ // Memory mapped pointers
+ //
+ PVOID pCardRam;
+ PHIGHNIUDATA pDataWindow;
+ PNIU_CONTROL_AREA pNIU_Control;
+
+ //
+ // NIU general requests
+ //
+ USHORT NIU_Requests_Pending;
+ USHORT NIU_Request_Head,NIU_Request_Tail,NIU_Next_Request;
+
+ NIUREQUEST NiuRequest[DEFAULT_MAXIMUM_REQUESTS];
+
+ //
+ // Recieve stuff
+ //
+ PRBD pIndicatedRBD;
+ UINT PacketLen;
+
+ PUCHAR FirstCardBuffer;
+
+
+ //
+ // Init stuff
+ //
+
+
+} UBNEI_ADAPTER, * PUBNEI_ADAPTER;
+
+
+
+
+
+
+
+
+//
+// NIU general request
+//
+#define NIU_Cmd_Set_Multicast 8
+#define NIU_Cmd_Set_Filter 7
+#define NIU_Cmd_Open 4
+#define NIU_Cmd_Close 5
+#define NIU_Cmd_Reset 6
+
+
+#define NIU_SET_MULTICAST_LIST(_pAdapter,CallBack,_List,_Size) \
+ NIU_General_Request3( \
+ CallBack, \
+ (PVOID)_pAdapter, \
+ 8, \
+ _Size, \
+ _List)
+
+#define NIU_SET_FILTER(_pAdapter,CallBack,Filter) \
+ NIU_General_Request3( \
+ CallBack, \
+ (PVOID)_pAdapter, \
+ 7, \
+ Filter, \
+ NULL)
+
+#define NIU_OPEN_ADAPTER(_pAdapter,CallBack) \
+ NIU_General_Request3( \
+ CallBack, \
+ (PVOID)_pAdapter, \
+ 4, \
+ 0, \
+ NULL)
+
+#define NIU_CLOSE_ADAPTER(_pAdapter,CallBack) \
+ NIU_General_Request3( \
+ CallBack, \
+ (PVOID)_pAdapter, \
+ 5, \
+ 0, \
+ NULL)
+
+#define NIU_RESET_ADAPTER(_pAdapter,CallBack) \
+ NIU_General_Request3( \
+ CallBack, \
+ (PVOID)_pAdapter, \
+ 6, \
+ 0, \
+ NULL) \
+
+#define NIU_SET_STATION_ADDRESS(_pAdapter,CallBack,Address)\
+ NIU_General_Request3( \
+ CallBack, \
+ (PVOID)_pAdapter, \
+ 3, \
+ 0, \
+ Address) \
+
+
+
+
+
+
+
+
+
+#define INTERRUPT_ENABLED 0x02
+#define INTERRUPT_DISABLED 0x00
+#define RESET_SET 0x01
+#define RESET_CLEAR 0x00