|
|
1.1 ! root 1: #ifndef i386 // No INTEL system has a TurboChannel bus. ! 2: ! 3: /*++ ! 4: ! 5: Copyright (c) 1990 Microsoft Corporation ! 6: ! 7: Module Name: ! 8: ! 9: dectc.c ! 10: ! 11: Abstract: ! 12: ! 13: This is the implementation of the card specific callbacks for the ! 14: DEC TurboChannel option for the Advanced Micro Devices LANCE (Am 7990) ! 15: Ethernet controller. ! 16: ! 17: Author: ! 18: ! 19: Environment: ! 20: ! 21: Revision History: ! 22: ! 23: 31-Jul-1992 R.D. Lanser: ! 24: ! 25: Moved/copied code from 'lance.c' to this file for all DEC ! 26: TurboChannel (PMAD-AA) specific code. ! 27: ! 28: --*/ ! 29: ! 30: #include <ndis.h> ! 31: #include <efilter.h> ! 32: #include "lancehrd.h" ! 33: #include "lancesft.h" ! 34: #include "dectc.h" ! 35: ! 36: ! 37: NDIS_STATUS ! 38: LanceDecTcGetConfiguration( ! 39: NDIS_HANDLE ConfigHandle, ! 40: PLANCE_ADAPTER PAdapter ! 41: ) ! 42: /*++ ! 43: Routine Description: ! 44: ! 45: This is the Digital TurboChannel configuration routine. This routine ! 46: extracts configuration information from the configuration data base. ! 47: ! 48: Arguments: ! 49: ! 50: ConfigHandle - Handle for configuration database. ! 51: PAdapter - Pointer for the adapter root. ! 52: ! 53: Return Value: ! 54: ! 55: NDIS_STATUS_SUCCESS - Configuration get was successfully. ! 56: NDIS_STATUS_FAILURE - Configuration get was unsuccessfully. ! 57: ! 58: --*/ ! 59: ! 60: ! 61: { ! 62: NDIS_STATUS status = NDIS_STATUS_SUCCESS; ! 63: ! 64: enum { ! 65: CS_FIRST_INDEX = 0, ! 66: INTERRUPT_VECTOR = CS_FIRST_INDEX, ! 67: IRQL, ! 68: BASE_ADDR, ! 69: CS_NUM_OF_ENTRIES ! 70: } csIndex; ! 71: ! 72: NDIS_STRING configString[CS_NUM_OF_ENTRIES] = { ! 73: NDIS_STRING_CONST("InterruptVector"), ! 74: NDIS_STRING_CONST("InterruptRequestLevel"), ! 75: NDIS_STRING_CONST("BaseAddress"), ! 76: }; ! 77: ! 78: UINT csCount = 0; ! 79: ! 80: for (csIndex = CS_FIRST_INDEX; csIndex < CS_NUM_OF_ENTRIES; csIndex++) { ! 81: ! 82: NDIS_STATUS returnedStatus; ! 83: PNDIS_CONFIGURATION_PARAMETER returnedValue; ! 84: ! 85: // ! 86: // Read the configuration entry ! 87: // ! 88: ! 89: NdisReadConfiguration( ! 90: &returnedStatus, ! 91: &returnedValue, ! 92: ConfigHandle, ! 93: &(configString[csIndex]), ! 94: NdisParameterInteger ! 95: ); ! 96: ! 97: if (returnedStatus == NDIS_STATUS_SUCCESS) { ! 98: ! 99: switch (csIndex) { ! 100: ! 101: case INTERRUPT_VECTOR: ! 102: PAdapter->InterruptNumber = ! 103: returnedValue->ParameterData.IntegerData; ! 104: break; ! 105: case IRQL: ! 106: PAdapter->InterruptRequestLevel = ! 107: returnedValue->ParameterData.IntegerData; ! 108: break; ! 109: case BASE_ADDR: ! 110: PAdapter->HardwareBaseAddr = (PVOID) ! 111: (returnedValue->ParameterData.IntegerData); ! 112: break; ! 113: default: ! 114: continue; ! 115: } ! 116: ! 117: csCount++; ! 118: ! 119: } else { ! 120: ! 121: status = returnedStatus; ! 122: ! 123: #if DBG ! 124: { ! 125: PCCHAR str[CS_NUM_OF_ENTRIES] = { ! 126: "InterruptVector", ! 127: "InterruptRequestLevel", ! 128: "BaseAddress" ! 129: } ; ! 130: DbgPrint("LANCE: Configuration parameter '%s' not found", ! 131: str[csIndex]); ! 132: } ! 133: #endif ! 134: ! 135: } ! 136: ! 137: } // for (csIndex ... ! 138: ! 139: // ! 140: // Fill in the rest of the configuration. ! 141: // ! 142: ! 143: if (status == NDIS_STATUS_SUCCESS) { ! 144: if (csCount == CS_NUM_OF_ENTRIES) { ! 145: ! 146: // ! 147: // Treat the RAP, RDP, and NetworkHardwareAddress as port numbers ! 148: // (offsets from the first register). This will allow the ! 149: // usage of the Ndis{Read/Write}Portxxx macros after the port ! 150: // offset address is fixed up in LanceDecTcSoftwareDetails. ! 151: // ! 152: ! 153: // ! 154: // The amount of dual ported memory. ! 155: // ! 156: PAdapter->AmountOfHardwareMemory = LANCE_DECTC_HARDWARE_MEMORY; ! 157: // ! 158: // The offset of this memory from the base address. ! 159: // ! 160: PAdapter->HardwareBaseOffset = 0; ! 161: // ! 162: // The register offsets from the base address. ! 163: // ! 164: PAdapter->RAP = (ULONG) LANCE_DECTC_RAP_OFFSET; ! 165: PAdapter->RDP = (ULONG) LANCE_DECTC_RDP_OFFSET; ! 166: // ! 167: // Not used for this adapter, simply null it. ! 168: // ! 169: PAdapter->Nicsr = (ULONG)NULL; ! 170: // ! 171: // And the offset from the base address for the hardware address. ! 172: // ! 173: PAdapter->NetworkHardwareAddress = LANCE_DECTC_NETWORK_OFFSET; ! 174: ! 175: } else { ! 176: ! 177: // ! 178: // Insufficient configuration data. ! 179: // ! 180: status = NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION; ! 181: ! 182: } ! 183: } ! 184: ! 185: return status; ! 186: } ! 187: ! 188: NDIS_STATUS ! 189: LanceDecTcGetInformation( ! 190: PLANCE_ADAPTER PAdapter, ! 191: PNDIS_ADAPTER_INFORMATION PAdapterInformation ! 192: ) ! 193: /*++ ! 194: Routine Description: ! 195: ! 196: This routine completes any additional setup after the adapter is registered. ! 197: ! 198: Arguments: ! 199: ! 200: PAdapter - Pointer for the adapter root. ! 201: ! 202: PAdapterInformation - Pointer for adapter information structure. ! 203: ! 204: Return Value: ! 205: ! 206: ! 207: NDIS_STATUS_SUCCESS - Information get was successfully. ! 208: NDIS_STATUS_FAILURE - Information get was unsuccessfully. ! 209: ! 210: --*/ ! 211: ! 212: ! 213: { ! 214: ! 215: // ! 216: // This is not an ISA/EISA adapter and uses memory mapped registers. ! 217: // Therefore, simply utilize the Ndis code like these were I/O ports ! 218: // by setting the InitialPort to the HardwareBaseAddress and the ! 219: // NumberOfPorts to the number of bytes to map. LanceDecTcSoftwareDetails ! 220: // sets the port offset to be the memory mapped address of the registers. ! 221: // The port number is then offset from this base address. ! 222: // The NdisRead/WritePortxxxx macros end up being read/write ! 223: // register code for non-INTEL systems and it all just works. ! 224: // ! 225: ! 226: PAdapterInformation->DmaChannel = PAdapter->InterruptNumber; ! 227: PAdapterInformation->AdapterType = NdisInterfaceTurboChannel; ! 228: ! 229: // ! 230: // PhysicalMapRegistersNeeded determines how many channesl to allocate. ! 231: // ! 232: ! 233: PAdapterInformation->PhysicalMapRegistersNeeded = 0; ! 234: ! 235: // ! 236: // MaximumPhysicalMapping determines how many map registers are ! 237: // needed per channel. ! 238: // ! 239: ! 240: PAdapterInformation->MaximumPhysicalMapping = 0; ! 241: ! 242: // ! 243: // Number of port descriptors says how many map regions there will be. ! 244: // ! 245: ! 246: PAdapterInformation->NumberOfPortDescriptors = 1; ! 247: ! 248: // ! 249: // Ask for all registers and the network hardware address to be mapped. ! 250: // ! 251: ! 252: PAdapterInformation->PortDescriptors[0].InitialPort = ! 253: (ULONG)(PAdapter->HardwareBaseAddr) + LANCE_DECTC_REGISTER_OFFSET; ! 254: PAdapterInformation->PortDescriptors[0].NumberOfPorts = ! 255: LANCE_DECTC_REGISTER_MAPSIZE; ! 256: ! 257: return NDIS_STATUS_SUCCESS; ! 258: } ! 259: ! 260: NDIS_STATUS ! 261: LanceDecTcSoftwareDetails( ! 262: PLANCE_ADAPTER PAdapter ! 263: ) ! 264: /*++ ! 265: Routine Description: ! 266: ! 267: Set buffer sizes and number of rings. Also, fixe the port mapping ! 268: offset address to avoid large unsigned subtractions in NDIS. See ! 269: the following macros in lancehrd.h: ! 270: ! 271: LANCE_ISR_WRITE_RAP(A,C) NdisWritePortUshort (... ! 272: LANCE_ISR_READ_RDP(A,C) NdisReadPortUshort (... ! 273: LANCE_ISR_WRITE_RDP(A,C) NdisWritePortUshort (... ! 274: LANCE_ISR_WRITE_NICSR(A,C) NdisWritePortUshort (... ! 275: ! 276: The port offset is the mapped address base, and the port number is ! 277: the offset from that base (confused yet?). ! 278: ! 279: Arguments: ! 280: ! 281: PAdapter - Pointer for the adapter root. ! 282: ! 283: Return Value: ! 284: ! 285: NDIS_STATUS_SUCCESS - Configuration get was successfully. ! 286: NDIS_STATUS_RESOURCES - Insufficient resources. ! 287: ! 288: --*/ ! 289: ! 290: ! 291: { ! 292: NDIS_STATUS status = NDIS_STATUS_SUCCESS; ! 293: PNDIS_ADAPTER_BLOCK adapterBlock = PAdapter->NdisAdapterHandle; ! 294: ! 295: // ! 296: // Patch up the PortOffset for NdisWritePortxxx and NdisReadPortxxx. ! 297: // The port number is now simply the offset from the first register. ! 298: // ! 299: ! 300: adapterBlock->PortOffset = adapterBlock->InitialPortMapping; ! 301: ! 302: // ! 303: // Set buffer sizes and number of rings. ! 304: // ! 305: ! 306: PAdapter->SizeOfReceiveBuffer = LANCE_128K_SIZE_OF_RECEIVE_BUFFERS; ! 307: PAdapter->NumberOfSmallBuffers = LANCE_128K_NUMBER_OF_SMALL_BUFFERS; ! 308: PAdapter->NumberOfMediumBuffers= LANCE_128K_NUMBER_OF_MEDIUM_BUFFERS; ! 309: PAdapter->NumberOfLargeBuffers = LANCE_128K_NUMBER_OF_LARGE_BUFFERS; ! 310: ! 311: PAdapter->NumberOfReceiveRings = LANCE_128K_NUMBER_OF_RECEIVE_RINGS; ! 312: PAdapter->LogNumberReceiveRings = LANCE_128K_LOG_RECEIVE_RINGS; ! 313: ! 314: return NDIS_STATUS_SUCCESS; ! 315: } ! 316: ! 317: NDIS_STATUS ! 318: LanceDecTcHardwareDetails( ! 319: PLANCE_ADAPTER PAdapter ! 320: ) ! 321: /*++ ! 322: Routine Description: ! 323: ! 324: This routine extracts the network hardware address. ! 325: ! 326: Arguments: ! 327: ! 328: PAdapter - Pointer for the adapter root. ! 329: ! 330: Return Value: ! 331: ! 332: ! 333: NDIS_STATUS_SUCCESS - Success. ! 334: NDIS_STATUS_FAILURE - Failure. ! 335: ! 336: --*/ ! 337: ! 338: ! 339: { ! 340: NDIS_HANDLE handle = PAdapter->NdisAdapterHandle; ! 341: ULONG port; ! 342: ULONG registerValue; ! 343: ! 344: ! 345: ! 346: port = (ULONG)(PAdapter->NetworkHardwareAddress); ! 347: NdisReadPortUlong(handle, port, ®isterValue); ! 348: ! 349: registerValue = (registerValue & 0x00ff0000u) >> 16; ! 350: PAdapter->NetworkAddress[0] = registerValue; ! 351: ! 352: port += sizeof(ULONG); ! 353: NdisReadPortUlong(handle, port, ®isterValue); ! 354: registerValue = (registerValue & 0x00ff0000u) >> 16; ! 355: PAdapter->NetworkAddress[1] = registerValue; ! 356: ! 357: ! 358: port += sizeof(ULONG); ! 359: NdisReadPortUlong(handle, port, ®isterValue); ! 360: registerValue = (registerValue & 0x00ff0000u) >> 16; ! 361: PAdapter->NetworkAddress[2] = registerValue; ! 362: ! 363: ! 364: port += sizeof(ULONG); ! 365: NdisReadPortUlong(handle, port, ®isterValue); ! 366: registerValue = (registerValue & 0x00ff0000u) >> 16; ! 367: PAdapter->NetworkAddress[3] = registerValue; ! 368: ! 369: ! 370: port += sizeof(ULONG); ! 371: NdisReadPortUlong(handle, port, ®isterValue); ! 372: registerValue = (registerValue & 0x00ff0000u) >> 16; ! 373: PAdapter->NetworkAddress[4] = registerValue; ! 374: ! 375: ! 376: port += sizeof(ULONG); ! 377: NdisReadPortUlong(handle, port, ®isterValue); ! 378: registerValue = (registerValue & 0x00ff0000u) >> 16; ! 379: PAdapter->NetworkAddress[5] = registerValue; ! 380: ! 381: return NDIS_STATUS_SUCCESS; ! 382: } ! 383: #endif // i386
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.