Annotation of ntddk/src/network/lance/details.c, revision 1.1

1.1     ! root        1: /*++
        !             2: 
        !             3: Copyright (c) 1990  Microsoft Corporation
        !             4: 
        !             5: Module Name:
        !             6: 
        !             7:     transfer.c
        !             8: 
        !             9: Abstract:
        !            10: 
        !            11:     This file implements the routine that does very architecture
        !            12:     specific things.
        !            13: 
        !            14: Author:
        !            15: 
        !            16:     Anthony V. Ercolano (Tonye) 02-Oct-1990
        !            17: 
        !            18: Environment:
        !            19: 
        !            20:     Kernel Mode - Or whatever is the equivalent on OS/2 and DOS.
        !            21: 
        !            22: Revision History:
        !            23: 
        !            24:     Sean Selitrennikoff (SeanSe) 10/20/91
        !            25:         Added code to deal with a DecstationPC
        !            26: 
        !            27:     31-Jul-1992  R.D. Lanser:
        !            28: 
        !            29:        Moved DEC TurboChannel (PMAD-AA) code to adapter specific routine.
        !            30: 
        !            31: --*/
        !            32: 
        !            33: 
        !            34: #include <ndis.h>
        !            35: #include <efilter.h>
        !            36: #include <lancehrd.h>
        !            37: #include <lancesft.h>
        !            38: 
        !            39: 
        !            40: extern
        !            41: BOOLEAN
        !            42: LanceHardwareDetails(
        !            43:     IN PLANCE_ADAPTER Adapter
        !            44:     )
        !            45: 
        !            46: /*++
        !            47: 
        !            48: Routine Description:
        !            49: 
        !            50:     This routine gets the network address from the hardware.
        !            51: 
        !            52: Arguments:
        !            53: 
        !            54:     Adapter - Where to store the network address.
        !            55: 
        !            56: Return Value:
        !            57: 
        !            58:     TRUE - if successful.
        !            59: 
        !            60: --*/
        !            61: 
        !            62: {
        !            63:     UCHAR Signature[] = { 0xff, 0x00, 0x55, 0xaa, 0xff, 0x00, 0x55, 0xaa};
        !            64:     UCHAR BytesRead[8];
        !            65: 
        !            66:     UINT ReadCount;
        !            67: 
        !            68:     UINT Place;
        !            69: 
        !            70:     //
        !            71:     // Reset E-PROM state
        !            72:     //
        !            73:     // To do this we first read from the E-PROM address until the
        !            74:     // specific signature is reached (then the next bytes read from
        !            75:     // the E-PROM address will be the ethernet address of the card).
        !            76:     //
        !            77: 
        !            78: 
        !            79: 
        !            80:     //
        !            81:     // Read first part of the signature
        !            82:     //
        !            83: 
        !            84:     for (Place=0; Place < 8; Place++){
        !            85: 
        !            86:         NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !            87:                           (ULONG)(Adapter->NetworkHardwareAddress),
        !            88:                           &(BytesRead[Place]));
        !            89: 
        !            90:     }
        !            91: 
        !            92:     ReadCount = 8;
        !            93: 
        !            94:     //
        !            95:     // This advances to the front of the circular buffer.
        !            96:     //
        !            97: 
        !            98:     while (ReadCount < 40) {
        !            99: 
        !           100:         //
        !           101:         // Check if we have read the signature.
        !           102:         //
        !           103: 
        !           104:         for (Place = 0; Place < 8; Place++){
        !           105: 
        !           106:             if (BytesRead[Place] != Signature[Place]){
        !           107: 
        !           108:                 Place = 10;
        !           109:                 break;
        !           110: 
        !           111:             }
        !           112: 
        !           113:         }
        !           114: 
        !           115:         //
        !           116:         // If we have read the signature, stop.
        !           117:         //
        !           118: 
        !           119:         if (Place != 10){
        !           120: 
        !           121:             break;
        !           122: 
        !           123:         }
        !           124: 
        !           125:         //
        !           126:         // else, move all the bytes down one and read then
        !           127:         // next byte.
        !           128:         //
        !           129: 
        !           130:         for (Place = 0; Place < 7; Place++){
        !           131: 
        !           132:             BytesRead[Place] = BytesRead[Place+1];
        !           133: 
        !           134:         }
        !           135: 
        !           136:         NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           137:                           (ULONG)(Adapter->NetworkHardwareAddress),
        !           138:                           &(BytesRead[7]));
        !           139: 
        !           140:         ReadCount++;
        !           141:     }
        !           142: 
        !           143: 
        !           144:     if (ReadCount == 40){
        !           145: 
        !           146:         return(FALSE);
        !           147: 
        !           148:     }
        !           149: 
        !           150: 
        !           151:     //
        !           152:     // Now read the ethernet address of the card.
        !           153:     //
        !           154: 
        !           155: 
        !           156:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           157:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           158:                       &(Adapter->NetworkAddress[0])
        !           159:                       );
        !           160:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           161:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           162:                       &(Adapter->NetworkAddress[1])
        !           163:                       );
        !           164:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           165:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           166:                       &(Adapter->NetworkAddress[2])
        !           167:                       );
        !           168:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           169:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           170:                       &(Adapter->NetworkAddress[3])
        !           171:                       );
        !           172:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           173:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           174:                       &(Adapter->NetworkAddress[4])
        !           175:                       );
        !           176:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           177:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           178:                       &(Adapter->NetworkAddress[5])
        !           179:                       );
        !           180: 
        !           181: 
        !           182: 
        !           183:     if (!(Adapter->LanceCard & (LANCE_DE201 | LANCE_DE422))) {
        !           184: 
        !           185:         if (Adapter->LanceCard == LANCE_DEPCA){
        !           186: 
        !           187:             //
        !           188:             // Reset Lan Interface port.
        !           189:             //
        !           190: 
        !           191:             NdisWritePortUchar(Adapter->NdisAdapterHandle,
        !           192:                                (ULONG)(LANCE_DEPCA_LAN_CFG_ADDRESS),
        !           193:                                0x00);
        !           194: 
        !           195:             //
        !           196:             // Reset Network Interface Control Status Register
        !           197:             //
        !           198: 
        !           199:             NdisWritePortUshort(Adapter->NdisAdapterHandle, (ULONG)(Adapter->Nicsr), 0x00);
        !           200:         }
        !           201: 
        !           202:         return(TRUE);
        !           203: 
        !           204:     }
        !           205: 
        !           206: 
        !           207: 
        !           208: 
        !           209:     //
        !           210:     // Now do the EPROM Hardware check as outlined in the tech ref.
        !           211:     //
        !           212: 
        !           213: 
        !           214:     //
        !           215:     // Check for NULL address.
        !           216:     //
        !           217: 
        !           218:     for (Place = 0; Place < 6; Place++) {
        !           219: 
        !           220:         if (Adapter->NetworkAddress[Place] != 0) {
        !           221: 
        !           222:             Place = 10;
        !           223:             break;
        !           224: 
        !           225:         }
        !           226: 
        !           227:     }
        !           228: 
        !           229:     if (Place != 10) {
        !           230: 
        !           231:         return(FALSE);
        !           232: 
        !           233:     }
        !           234: 
        !           235: 
        !           236: 
        !           237:     //
        !           238:     // Check that bit 0 is not a 1
        !           239:     //
        !           240: 
        !           241:     if (Adapter->NetworkAddress[0] & 0x1) {
        !           242: 
        !           243:         return(FALSE);
        !           244: 
        !           245:     }
        !           246: 
        !           247: 
        !           248: 
        !           249: 
        !           250: 
        !           251:     //
        !           252:     // Check that octet[0]->octet[7] == octet[15]->octet[8]
        !           253:     //
        !           254: 
        !           255:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           256:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           257:                       &(BytesRead[6])
        !           258:                       );
        !           259:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           260:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           261:                       &(BytesRead[7])
        !           262:                       );
        !           263: 
        !           264:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           265:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           266:                       &(BytesRead[0])
        !           267:                       );
        !           268:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           269:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           270:                       &(BytesRead[1])
        !           271:                       );
        !           272: 
        !           273:     if ((BytesRead[7] != BytesRead[0]) ||
        !           274:         (BytesRead[6] != BytesRead[1])) {
        !           275: 
        !           276:         return(FALSE);
        !           277: 
        !           278:     }
        !           279: 
        !           280: 
        !           281:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           282:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           283:                       &(BytesRead[5])
        !           284:                       );
        !           285:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           286:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           287:                       &(BytesRead[4])
        !           288:                       );
        !           289:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           290:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           291:                       &(BytesRead[3])
        !           292:                       );
        !           293:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           294:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           295:                       &(BytesRead[2])
        !           296:                       );
        !           297:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           298:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           299:                       &(BytesRead[1])
        !           300:                       );
        !           301:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           302:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           303:                       &(BytesRead[0])
        !           304:                       );
        !           305: 
        !           306:     for (Place = 0; Place < 6; Place++) {
        !           307: 
        !           308:         if (BytesRead[Place] != (UCHAR)(Adapter->NetworkAddress[Place])) {
        !           309: 
        !           310:             return(FALSE);
        !           311: 
        !           312:         }
        !           313: 
        !           314:     }
        !           315: 
        !           316: 
        !           317:     //
        !           318:     // Check that octet[0]->octet[8] == octet[16]->octet[23]
        !           319:     //
        !           320: 
        !           321:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           322:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           323:                       &(BytesRead[0])
        !           324:                       );
        !           325:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           326:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           327:                       &(BytesRead[1])
        !           328:                       );
        !           329:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           330:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           331:                       &(BytesRead[2])
        !           332:                       );
        !           333:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           334:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           335:                       &(BytesRead[3])
        !           336:                       );
        !           337:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           338:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           339:                       &(BytesRead[4])
        !           340:                       );
        !           341:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           342:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           343:                       &(BytesRead[5])
        !           344:                       );
        !           345: 
        !           346:     for (Place = 0; Place < 6; Place++) {
        !           347: 
        !           348:         if (BytesRead[Place] != (UCHAR)(Adapter->NetworkAddress[Place])) {
        !           349: 
        !           350:             return(FALSE);
        !           351: 
        !           352:         }
        !           353: 
        !           354:     }
        !           355: 
        !           356: 
        !           357:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           358:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           359:                       &(BytesRead[0])
        !           360:                       );
        !           361:     NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           362:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           363:                       &(BytesRead[1])
        !           364:                       );
        !           365: 
        !           366:     if ((BytesRead[6] != BytesRead[0]) ||
        !           367:         (BytesRead[7] != BytesRead[1])) {
        !           368: 
        !           369:         return(FALSE);
        !           370: 
        !           371:     }
        !           372: 
        !           373:     //
        !           374:     // Check that octet[24] -> octet[31] == signature bytes
        !           375:     //
        !           376: 
        !           377: 
        !           378:     for (Place = 0; Place < 8; Place++){
        !           379: 
        !           380: 
        !           381:         NdisReadPortUchar(Adapter->NdisAdapterHandle,
        !           382:                       (ULONG)(Adapter->NetworkHardwareAddress),
        !           383:                       &(BytesRead[Place])
        !           384:                       );
        !           385: 
        !           386:         if (BytesRead[Place] != Signature[Place]){
        !           387: 
        !           388: #if DBG
        !           389:             DbgPrint("Lance: Hardware failure\n");
        !           390: #endif
        !           391:             return(FALSE);
        !           392: 
        !           393:         }
        !           394: 
        !           395:     }
        !           396: 
        !           397:     if (Adapter->LanceCard == LANCE_DEPCA){
        !           398: 
        !           399:         //
        !           400:         // Reset Lan Interface port.
        !           401:         //
        !           402: 
        !           403:         NdisWritePortUchar(Adapter->NdisAdapterHandle,
        !           404:                            (ULONG)(LANCE_DEPCA_LAN_CFG_ADDRESS),
        !           405:                            0x00);
        !           406: 
        !           407:         //
        !           408:         // Reset Network Interface Control Status Register
        !           409:         //
        !           410: 
        !           411:         NdisWritePortUshort(Adapter->NdisAdapterHandle, (ULONG)(Adapter->Nicsr), 0x00);
        !           412:     }
        !           413: 
        !           414:     if (Adapter->LanceCard & (LANCE_DE201 | LANCE_DE422)) {
        !           415: 
        !           416:         //
        !           417:         // Reset Network Interface Control Status Register
        !           418:         //
        !           419: 
        !           420:         NdisWritePortUshort(Adapter->NdisAdapterHandle, (ULONG)(Adapter->Nicsr), 0x00);
        !           421: 
        !           422:     }
        !           423: 
        !           424:     return(TRUE);
        !           425: 
        !           426: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.