|
|
1.1 ! root 1: /*++ ! 2: ! 3: Copyright (c) 1990 Microsoft Corporation ! 4: ! 5: Module Name: ! 6: ! 7: toksft.h ! 8: ! 9: Abstract: ! 10: ! 11: The main header for a IBMTOK NDIS driver. ! 12: ! 13: The overall structure is taken from the Lance driver ! 14: by Tony Ercolano. ! 15: ! 16: Author: ! 17: ! 18: Anthony V. Ercolano (tonye) creation-date 19-Jun-1990 ! 19: Adam Barr (adamba) 20-Nov-1990 ! 20: ! 21: Environment: ! 22: ! 23: Architecturally, there is an assumption in this driver that we are ! 24: on a little endian machine. ! 25: ! 26: Notes: ! 27: ! 28: optional-notes ! 29: ! 30: Revision History: ! 31: ! 32: ! 33: --*/ ! 34: ! 35: #ifndef _IBMTOKSFT_ ! 36: #define _IBMTOKSFT_ ! 37: ! 38: ! 39: #define IBMTOK_NDIS_MAJOR_VERSION 3 ! 40: #define IBMTOK_NDIS_MINOR_VERSION 0 ! 41: ! 42: ! 43: #if DBG ! 44: #define LOG 1 ! 45: #else ! 46: #define LOG 0 ! 47: #endif ! 48: ! 49: extern const NDIS_PHYSICAL_ADDRESS HighestAcceptableMax; ! 50: ! 51: #define IBMTOK_ALLOC_PHYS(pp,s) NdisAllocateMemory((PVOID *)(pp),(s),0,HighestAcceptableMax) ! 52: #define IBMTOK_FREE_PHYS(p,s) NdisFreeMemory((PVOID)(p),(s),0) ! 53: #define IBMTOK_MOVE_MEMORY(Destination,Source,Length) NdisMoveMemory((PVOID)(Destination),(PVOID)(Source),Length) ! 54: #define IBMTOK_ZERO_MEMORY(Destination,Length) NdisZeroMemory((PVOID)(Destination),Length) ! 55: #define IBMTOK_MOVE_TO_MAPPED_MEMORY(Destination,Source,Length) NdisMoveToMappedMemory((PVOID)(Destination),(PVOID)(Source),Length) ! 56: #define IBMTOK_MOVE_FROM_MAPPED_MEMORY(Destination,Source,Length) NdisMoveFromMappedMemory((PVOID)(Destination),(PVOID)(Source),Length) ! 57: #define IBMTOK_ZERO_MAPPED_MEMORY(Destination,Length) NdisZeroMappedMemory((PVOID)(Destination),Length) ! 58: #define IBMTOK_STORE_ULONG(Destination,Source)\ ! 59: {\ ! 60: PUCHAR _D = (PUCHAR)(Destination);\ ! 61: ULONG _S = (ULONG)(Source);\ ! 62: _D[0] = (UCHAR)(_S >> 24);\ ! 63: _D[1] = (UCHAR)(_S >> 16);\ ! 64: _D[2] = (UCHAR)(_S >> 8);\ ! 65: _D[3] = (UCHAR)(_S);\ ! 66: } ! 67: ! 68: ! 69: typedef struct _IBMTOK_MAC { ! 70: ! 71: // ! 72: // The handle returned by NdisInitializeWrapper. ! 73: // ! 74: ! 75: NDIS_HANDLE NdisWrapperHandle; ! 76: ! 77: // ! 78: // The handle returned by NdisRegisterMac. ! 79: // ! 80: ! 81: NDIS_HANDLE NdisMacHandle; ! 82: ! 83: } IBMTOK_MAC, *PIBMTOK_MAC; ! 84: ! 85: ! 86: ! 87: // ! 88: // This record type is inserted into the MacReserved portion ! 89: // of the packet header when the packet is going through the ! 90: // staged allocation of buffer space prior to the actual send. ! 91: // ! 92: typedef struct _IBMTOK_RESERVED { ! 93: ! 94: // ! 95: // Points to the next packet in the chain of queued packets ! 96: // waiting for the SRB or the ASB. ! 97: // ! 98: // The packet will start out on the Transmit queue, ! 99: // then move to TransmittingPacket when its transmit is ! 100: // in the SRB. When the correlator is assigned it is placed ! 101: // in CorrelatorArray (where the Next field is not used), ! 102: // and at that time may also be in WaitingForAsb if it ! 103: // needs the ASB to acknowledge the copying down of the ! 104: // transmit data. Packets are completed out of the ! 105: // CorrelatorArray. ! 106: // ! 107: // ! 108: PNDIS_PACKET Next; ! 109: ! 110: // ! 111: // This field holds the binding handle of the open binding ! 112: // that submitted this packet for send. ! 113: // ! 114: NDIS_HANDLE MacBindingHandle; ! 115: ! 116: // ! 117: // This field holds the pointer to the packet so that when ! 118: // the send finnaly completes it can be used to indicate to ! 119: // the protocol. ! 120: // ! 121: PNDIS_PACKET Packet; ! 122: ! 123: // ! 124: // TRUE if a command correlator has been assigned for this ! 125: // packet. ! 126: // ! 127: BOOLEAN CorrelatorAssigned; ! 128: ! 129: // ! 130: // The value of the adapter-assigned command correlator. ! 131: // ! 132: UCHAR CommandCorrelator; ! 133: ! 134: } IBMTOK_RESERVED,*PIBMTOK_RESERVED; ! 135: ! 136: ! 137: // ! 138: // This macro will return a pointer to the reserved portion ! 139: // of a packet given a pointer to a packet. ! 140: // ! 141: #define PIBMTOK_RESERVED_FROM_PACKET(Packet) \ ! 142: ((PIBMTOK_RESERVED)((PVOID)((Packet)->MacReserved))) ! 143: ! 144: ! 145: ! 146: // ! 147: // This structure is inserted into the MacReserved section of the ! 148: // NDIS_REQUEST for operations that must pend. Note: the sizeof ! 149: // this structure must be less than or equal to 16 bytes. ! 150: // ! 151: // The flags are broken down as follows.... ! 152: // ! 153: // Type == IBMTOK_PEND_MAC for requests submitted by the MAC to clear card errors. ! 154: // ReadLogPending == TRUE if the MAC submitted a DIR.READ.LOG command. ! 155: // ReadLogPending == FALSE if the MAC submitted DLC.STATISTICS. ! 156: // ! 157: // Type == IBMTOK_PEND_NDIS_CLOSE for request submitted thru Ndis. ! 158: // Open, the open that submitted the Ndis request. ! 159: // ! 160: // Type == IBMTOK_PEND_NDIS_SET_FILTER for request submitted thru Ndis. ! 161: // Open, the open that submitted the Ndis request. ! 162: // ! 163: // Type == IBMTOK_PEND_NDIS_STATISTICS for request submitted thru Ndis. ! 164: // ReadLogPending, Boolean if the DIR.READ.LOG command was submitted. ! 165: // ! 166: // ! 167: // ! 168: typedef struct _IBMTOK_PEND_DATA{ ! 169: ! 170: // ! 171: // Points to the next request in the chain of queued packets ! 172: // waiting for the SRB. ! 173: // ! 174: // The request will start out on the PendQueue, ! 175: // then move to front of the queue when its operation is ! 176: // in the SRB. ! 177: // ! 178: // ! 179: struct _IBMTOK_PEND_DATA * Next; ! 180: ! 181: ! 182: union _COMMAND{ ! 183: ! 184: struct _MAC{ ! 185: ! 186: // ! 187: // Whether the statistics command was a ! 188: // DIR.READ.LOG or DLC.STATISTICS ! 189: // ! 190: ! 191: UINT ReadLogPending; ! 192: ! 193: }MAC; ! 194: ! 195: union _NDIS{ ! 196: ! 197: struct _CLOSE{ ! 198: ! 199: // ! 200: // This field holds the open instance which submitted the ! 201: // request. ! 202: // ! 203: ! 204: struct _IBMTOK_OPEN *Open; ! 205: ! 206: // ! 207: // This field holds the new filter value. ! 208: // ! 209: ! 210: UINT NewFilterValue; ! 211: ! 212: ! 213: }CLOSE; ! 214: ! 215: ! 216: struct _SET_FILTER{ ! 217: ! 218: // ! 219: // The first two fields of SET_FILTER and SET_ADDRESS need ! 220: // to align so that the processing in FinishSetOperation ! 221: // is easier. ! 222: // ! 223: ! 224: ! 225: // ! 226: // This field holds the open instance which submitted the ! 227: // request. ! 228: // ! 229: ! 230: struct _IBMTOK_OPEN *Open; ! 231: ! 232: // ! 233: // This field holds the new filter value. ! 234: // ! 235: ! 236: UINT NewFilterValue; ! 237: ! 238: }SET_FILTER; ! 239: ! 240: ! 241: struct _SET_ADDRESS{ ! 242: ! 243: // ! 244: // The first two fields of SET_FILTER and SET_ADDRESS need ! 245: // to align so that the processing in FinishSetOperation ! 246: // is easier. ! 247: // ! 248: ! 249: ! 250: // ! 251: // This field holds the open instance which submitted the ! 252: // request. ! 253: // ! 254: ! 255: struct _IBMTOK_OPEN *Open; ! 256: ! 257: // ! 258: // This field holds the new address value. ! 259: // ! 260: ! 261: TR_FUNCTIONAL_ADDRESS NewAddressValue; ! 262: ! 263: }SET_ADDRESS; ! 264: ! 265: ! 266: struct _STATISTICS{ ! 267: ! 268: // ! 269: // Pointer into NdisRequest at the New filter value. ! 270: // ! 271: ! 272: BOOLEAN ReadLogPending; ! 273: ! 274: ! 275: }STATISTICS; ! 276: ! 277: }NDIS; ! 278: ! 279: }COMMAND; ! 280: ! 281: // ! 282: // Buffer to fill in Reserved section so that the next field overlaps ! 283: // with the RequestType in the NdisRequest. ! 284: // ! 285: ! 286: ULONG Buffer; ! 287: ! 288: ! 289: NDIS_REQUEST_TYPE RequestType; ! 290: ! 291: ! 292: }IBMTOK_PEND_DATA, *PIBMTOK_PEND_DATA; ! 293: ! 294: // ! 295: // This macro will return a pointer to the reserved area of ! 296: // a PNDIS_REQUEST. ! 297: // ! 298: #define PIBMTOK_PEND_DATA_FROM_PNDIS_REQUEST(Request) \ ! 299: ((PIBMTOK_PEND_DATA)((PVOID)((Request)->MacReserved))) ! 300: ! 301: // ! 302: // This macros returns the enclosing NdisRequest. ! 303: // ! 304: #define PNDIS_REQUEST_FROM_PIBMTOK_PEND_DATA(PendOp)\ ! 305: ((PNDIS_REQUEST)((PVOID)(PendOp))) ! 306: ! 307: // ! 308: // Define Maximum number of bytes a protocol can read during a ! 309: // receive data indication. ! 310: // ! 311: #define IBMTOK_MAX_LOOKAHEAD 208 ! 312: ! 313: ! 314: typedef struct _IBMTOK_ADAPTER { ! 315: ! 316: // ! 317: // Holds the interrupt object for this adapter. ! 318: // ! 319: NDIS_INTERRUPT Interrupt; ! 320: ! 321: // ! 322: // Flag to tell if the ISR removed the interrupt. ! 323: // ! 324: UCHAR ContinuousIsrs; ! 325: ! 326: PVOID WakeUpDpc; ! 327: NDIS_TIMER WakeUpTimer; ! 328: BOOLEAN WakeUpTimeout; ! 329: ! 330: // ! 331: // Flag to indicate that the card initialized. ! 332: // ! 333: BOOLEAN BringUp; ! 334: ! 335: // ! 336: // Spinlock for the interrupt. ! 337: // ! 338: NDIS_SPIN_LOCK InterruptLock; ! 339: ! 340: // ! 341: // The interrupt level as read from the card. ! 342: // ! 343: UINT InterruptLevel; ! 344: ! 345: // ! 346: // Is the adapter running at 16 Mbps (versus 4 Mbps). ! 347: // ! 348: BOOLEAN Running16Mbps; ! 349: ! 350: // ! 351: // Is the adapter using the PC I/O Bus (versus MicroChannel). ! 352: // ! 353: BOOLEAN UsingPcIoBus; ! 354: ! 355: // ! 356: // Does the upper 512 bytes of the shared RAM have to ! 357: // be zeroed after initialization. ! 358: // ! 359: BOOLEAN UpperSharedRamZero; ! 360: ! 361: // ! 362: // Are we using Shared RAM paging. ! 363: // ! 364: BOOLEAN SharedRamPaging; ! 365: ! 366: // ! 367: // The size of the RAM on the adapter. ! 368: // ! 369: ULONG TotalSharedRam; ! 370: ! 371: // ! 372: // The amount of Shared RAM to be mapped in. ! 373: // ! 374: ULONG MappedSharedRam; ! 375: ! 376: // ! 377: // The maximum size of a DHB at 4 Mbps. ! 378: // ! 379: USHORT Max4MbpsDhb; ! 380: ! 381: // ! 382: // The maximum size of a DHB at 16 Mbps. ! 383: // ! 384: USHORT Max16MbpsDhb; ! 385: ! 386: // ! 387: // Value of the RRR Low register (address of Shared Ram). ! 388: // ! 389: UCHAR RrrLowValue; ! 390: ! 391: // The following fields are accessed by the ISR and must be aligned to the ! 392: // minimum granularity of the architecture on which it runs ! 393: ! 394: #if defined(_ALPHA_) ! 395: ! 396: union { ! 397: UQUAD _ForceQuadwordAlignment; ! 398: struct { ! 399: ! 400: #endif // defined(_ALPHA_) ! 401: ! 402: // ! 403: // These variables are used to hold bits stored in the ISR ! 404: // and read in the DPC. ! 405: // ! 406: UCHAR IsrpBits; ! 407: ! 408: // ! 409: // These hold ISR bits whose processing is delayed because ! 410: // the adapter is not accepting requests. ! 411: // ! 412: UCHAR IsrpDeferredBits; ! 413: ! 414: // ! 415: // Any Error conditions found in the IsrpLow register ! 416: // ! 417: UCHAR IsrpLowBits; ! 418: ! 419: #if defined(_ALPHA_) ! 420: ! 421: }; ! 422: }; ! 423: ! 424: #endif // defined(_ALPHA_) ! 425: ! 426: // End of ISR access fields ! 427: ! 428: // ! 429: // This boolean is used as a gate to ensure that only one thread ! 430: // of execution is actually processing SRB interrupts ! 431: // ! 432: BOOLEAN HandleSrbRunning; ! 433: ! 434: // ! 435: // This boolean is used as a gate to ensure that only one thread ! 436: // of execution is actually processing SRB interrupts ! 437: // ! 438: BOOLEAN HandleArbRunning; ! 439: ! 440: // ! 441: // The network address in use. ! 442: // ! 443: CHAR NetworkAddress[TR_LENGTH_OF_ADDRESS]; ! 444: ! 445: // ! 446: // The network address from the hardware. ! 447: // ! 448: CHAR PermanentNetworkAddress[TR_LENGTH_OF_ADDRESS]; ! 449: ! 450: // ! 451: // Pointer to the beginning of the IBMTOK ports. ! 452: // ! 453: ULONG IbmtokPortAddress; ! 454: ! 455: // ! 456: // Keeps a reference count on the current number of uses of ! 457: // this adapter block. Uses is defined to be the number of ! 458: // routines currently within the "external" interface. ! 459: // ! 460: UINT References; ! 461: ! 462: // ! 463: // List head for all open bindings for this adapter. ! 464: // ! 465: LIST_ENTRY OpenBindings; ! 466: ! 467: // ! 468: // List head for all opens that had outstanding references ! 469: // when an attempt was made to close them. ! 470: // ! 471: LIST_ENTRY CloseList; ! 472: ! 473: // ! 474: // List head for all opens that were attempted to be closed ! 475: // during a reset. ! 476: LIST_ENTRY CloseDuringResetList; ! 477: ! 478: // ! 479: // Spinlock to protect fields in this structure.. ! 480: // ! 481: NDIS_SPIN_LOCK Lock; ! 482: ! 483: // ! 484: // Handle given by NDIS when the MAC registered itself. ! 485: // ! 486: NDIS_HANDLE NdisMacHandle; ! 487: ! 488: // ! 489: // Handle given by NDIS when the adapter was registered. ! 490: // ! 491: NDIS_HANDLE NdisAdapterHandle; ! 492: ! 493: // ! 494: // Pointer to the filter database for the MAC. ! 495: // ! 496: PTR_FILTER FilterDB; ! 497: ! 498: // ! 499: // Holds queued Pending operations. ! 500: // ! 501: PIBMTOK_PEND_DATA PendQueue; ! 502: ! 503: // ! 504: // Last pending operation on queue. ! 505: // ! 506: PIBMTOK_PEND_DATA EndOfPendQueue; ! 507: ! 508: // ! 509: // Pointer to the pended operation that is currently executing. ! 510: // ! 511: PIBMTOK_PEND_DATA PendData; ! 512: ! 513: // ! 514: // The current packet filter. ! 515: // ! 516: UINT CurrentPacketFilter; ! 517: ! 518: // ! 519: // The old packet filter (in case of failure to set to a new filter). ! 520: // ! 521: UINT OldPacketFilter; ! 522: ! 523: // ! 524: // The current functional address requested. ! 525: // ! 526: TR_FUNCTIONAL_ADDRESS CurrentFunctionalAddress; ! 527: ! 528: // ! 529: // The functional address on the card (may differ ! 530: // from CurrentFunctionalAddress if ALL_MULTICAST ! 531: // is selected). ! 532: // ! 533: TR_FUNCTIONAL_ADDRESS CurrentCardFunctional; ! 534: ! 535: // ! 536: // The current group address requested. ! 537: // ! 538: TR_FUNCTIONAL_ADDRESS CurrentGroupAddress; ! 539: ! 540: // ! 541: // The group address on the card ! 542: // ! 543: TR_FUNCTIONAL_ADDRESS CurrentCardGroup; ! 544: ! 545: // ! 546: // The address that the MMIO is mapped to. ! 547: // ! 548: PUCHAR MmioRegion; ! 549: ! 550: // ! 551: // The address that the Shared RAM is mapped to. ! 552: // ! 553: PUCHAR SharedRam; ! 554: ! 555: // ! 556: // Initial offset of WRB in Shared RAM (contains location ! 557: // of bring-up SRB). ! 558: // ! 559: USHORT InitialWrbOffset; ! 560: ! 561: // ! 562: // Addresses of the Shared RAM structures. ! 563: // ! 564: PVOID SrbAddress; ! 565: PVOID SsbAddress; ! 566: PVOID ArbAddress; ! 567: PVOID AsbAddress; ! 568: ! 569: // ! 570: // For Shared RAM Paging mode, the SRPR Low value needed ! 571: // to talk to each of the Shared RAM structures. ! 572: // ! 573: UCHAR SrbSrprLow; ! 574: UCHAR SsbSrprLow; ! 575: UCHAR ArbSrprLow; ! 576: UCHAR AsbSrprLow; ! 577: ! 578: // ! 579: // Is the SRB available. ! 580: // ! 581: BOOLEAN SrbAvailable; ! 582: ! 583: // ! 584: // Is the ASB available. ! 585: // ! 586: BOOLEAN AsbAvailable; ! 587: ! 588: // ! 589: // The next correlator number which we think we should ! 590: // be completing the send for. ! 591: // ! 592: UCHAR NextCorrelatorToComplete; ! 593: ! 594: // ! 595: // Points to the packet being transmitted if TransmitInSrb ! 596: // is TRUE. ! 597: // ! 598: PNDIS_PACKET TransmittingPacket; ! 599: ! 600: // ! 601: // The receive buffer that is waiting for the ASB. ! 602: // ! 603: SRAM_PTR ReceiveWaitingForAsbList; ! 604: ! 605: // ! 606: // A SRAM_PTR to the last receive buffer waiting for ! 607: // the ASB to indicate completion. ! 608: // ! 609: SRAM_PTR ReceiveWaitingForAsbEnd; ! 610: ! 611: ! 612: // ! 613: // The receive buffer that the transfer data should ! 614: // begin at (used during receive indications). ! 615: // ! 616: SRAM_PTR IndicatedReceiveBuffer; ! 617: ! 618: // ! 619: // Length of the header for this received indication. ! 620: // ! 621: USHORT IndicatedHeaderLength; ! 622: ! 623: // ! 624: // Should the ASB be used for a receive next. ! 625: // ! 626: BOOLEAN UseNextAsbForReceive; ! 627: ! 628: // ! 629: // The number of transmit buffers. ! 630: // ! 631: USHORT NumberOfTransmitBuffers; ! 632: ! 633: // ! 634: // The size of the transmit buffers. ! 635: // ! 636: USHORT TransmitBufferLength; ! 637: ! 638: // ! 639: // The size of the maximum packet transmittable. ! 640: // ! 641: UINT MaxTransmittablePacket; ! 642: ! 643: // ! 644: // The number of receive buffers. ! 645: // ! 646: USHORT NumberOfReceiveBuffers; ! 647: ! 648: // ! 649: // The size of the receive buffers. ! 650: // ! 651: USHORT ReceiveBufferLength; ! 652: ! 653: // ! 654: // Pointers to the first and last packets at a particular stage ! 655: // of allocation. All packets in transmit are linked ! 656: // via there next field. ! 657: // ! 658: // Can only be accessed when the adapter lock ! 659: // is held. ! 660: // ! 661: PNDIS_PACKET FirstTransmit; ! 662: PNDIS_PACKET LastTransmit; ! 663: ! 664: PNDIS_PACKET FirstWaitingForAsb; ! 665: PNDIS_PACKET LastWaitingForAsb; ! 666: ! 667: // ! 668: // Holds counter return by DLC.STATISTICS command. ! 669: // ! 670: ! 671: UINT FramesTransmitted; ! 672: UINT FramesReceived; ! 673: UINT FrameTransmitErrors; ! 674: UINT FrameReceiveErrors; ! 675: ! 676: ! 677: // ! 678: // Holds counter returned by the DIR.READ.LOG command. ! 679: // ! 680: UINT LineErrors; ! 681: UINT InternalErrors; ! 682: UINT BurstErrors; ! 683: UINT AcErrors; ! 684: UINT AbortDelimeters; ! 685: UINT LostFrames; ! 686: UINT ReceiveCongestionCount; ! 687: UINT FrameCopiedErrors; ! 688: UINT FrequencyErrors; ! 689: UINT TokenErrors; ! 690: ! 691: // ! 692: // Holds number of different types of RING.STATUS.CHANGE ! 693: // indications. ! 694: // ! 695: UINT SignalLoss; ! 696: UINT HardError; ! 697: UINT SoftError; ! 698: UINT TransmitBeacon; ! 699: UINT LobeWireFault; ! 700: UINT AutoRemovalError; ! 701: UINT RemoveReceived; ! 702: UINT CounterOverflow; ! 703: UINT SingleStation; ! 704: UINT RingRecovery; ! 705: ! 706: // ! 707: // Last ring status indicated to protocols. ! 708: // ! 709: NDIS_STATUS LastNotifyStatus; ! 710: ! 711: // ! 712: // Current state of the ring. ! 713: // ! 714: NDIS_802_5_RING_STATE CurrentRingState; ! 715: ! 716: // ! 717: // Flag that when enabled lets routines know that a reset ! 718: // is in progress. ! 719: // ! 720: BOOLEAN ResetInProgress; ! 721: ! 722: // ! 723: // The progress of the reset. ! 724: // ! 725: UINT CurrentResetStage; ! 726: ! 727: // ! 728: // LookAhead information ! 729: // ! 730: ! 731: ULONG LookAhead; ! 732: ! 733: // ! 734: // TRUE when the ISR is expecting the next interrupt to ! 735: // be the one following adapter reset. ! 736: // ! 737: BOOLEAN ResetInterruptAllowed; ! 738: ! 739: // ! 740: // TRUE when ISR gets the reset interrupt. ! 741: // ! 742: BOOLEAN ResetInterruptHasArrived; ! 743: ! 744: // ! 745: // Pointer to the binding that initiated the reset. This ! 746: // will be null if the reset is initiated by the MAC itself. ! 747: // ! 748: struct _IBMTOK_OPEN *ResettingOpen; ! 749: ! 750: // ! 751: // Will be true the first time that the hardware is initialized ! 752: // by the driver initialization. ! 753: // ! 754: BOOLEAN FirstInitialization; ! 755: ! 756: // ! 757: // Will be true if the adapter is not yet opened. ! 758: // ! 759: BOOLEAN AdapterNotOpen; ! 760: ! 761: // ! 762: // Will be true if the driver is being opened. ! 763: // ! 764: BOOLEAN OpenInProgress; ! 765: ! 766: // ! 767: // TRUE if ResetInProgress or OpenInProgress is TRUE. ! 768: // ! 769: BOOLEAN NotAcceptingRequests; ! 770: ! 771: // ! 772: // Last Error Code. ! 773: // ! 774: USHORT OpenErrorCode; ! 775: ! 776: // ! 777: // TRUE if we get a ring status indicating the cable is unplugged. ! 778: // ! 779: BOOLEAN Unplugged; ! 780: ! 781: // ! 782: // TRUE if we are doing a reset after the cable was unplugged ! 783: // to try to reenter the ring. ! 784: // ! 785: BOOLEAN UnpluggedResetInProgress; ! 786: ! 787: // ! 788: // TRUE if we have gotten a lobe wire fault indication, ! 789: // meaning the adapter is closed. ! 790: // ! 791: BOOLEAN LobeWireFaultIndicated; ! 792: ! 793: // ! 794: // TRUE if there exists an outstanding ASB_FREE_REQUEST ! 795: // ! 796: BOOLEAN OutstandingAsbFreeRequest; ! 797: ! 798: // ! 799: // The command correlator array (put this at the end since ! 800: // it is so big). ! 801: // ! 802: PNDIS_PACKET CorrelatorArray[MAX_COMMAND_CORRELATOR]; ! 803: ! 804: } IBMTOK_ADAPTER,*PIBMTOK_ADAPTER; ! 805: ! 806: ! 807: // ! 808: // Given a MacBindingHandle this macro returns a pointer to the ! 809: // IBMTOK_ADAPTER. ! 810: // ! 811: #define PIBMTOK_ADAPTER_FROM_BINDING_HANDLE(Handle) \ ! 812: (((PIBMTOK_OPEN)((PVOID)(Handle)))->OwningIbmtok) ! 813: ! 814: ! 815: // ! 816: // Given a MacContextHandle return the PIBMTOK_ADAPTER ! 817: // it represents. ! 818: // ! 819: #define PIBMTOK_ADAPTER_FROM_CONTEXT_HANDLE(Handle) \ ! 820: ((PIBMTOK_ADAPTER)((PVOID)(Handle))) ! 821: ! 822: ! 823: // ! 824: // Given a pointer to a IBMTOK_ADAPTER return the ! 825: // proper MacContextHandle. ! 826: // ! 827: #define CONTEXT_HANDLE_FROM_PIBMTOK_ADAPTER(Ptr) \ ! 828: ((NDIS_HANDLE)((PVOID)(Ptr))) ! 829: ! 830: ! 831: // ! 832: // One of these structures is created on each MacOpenAdapter. ! 833: // ! 834: typedef struct _IBMTOK_OPEN { ! 835: ! 836: // ! 837: // Linking structure for all of the open bindings of a particular ! 838: // adapter. ! 839: // ! 840: LIST_ENTRY OpenList; ! 841: ! 842: // ! 843: // The Adapter that requested this open binding. ! 844: // ! 845: PIBMTOK_ADAPTER OwningIbmtok; ! 846: ! 847: // ! 848: // Handle of this adapter in the filter database. ! 849: // ! 850: NDIS_HANDLE NdisFilterHandle; ! 851: ! 852: // ! 853: // Given by NDIS when the adapter was opened. ! 854: // ! 855: NDIS_HANDLE NdisBindingContext; ! 856: ! 857: // ! 858: // Counter of all the different reasons that a open binding ! 859: // couldn't be closed. This would be incremented each time ! 860: // for: ! 861: // ! 862: // While a particular interface routine is accessing this open ! 863: // ! 864: // During an indication. ! 865: // ! 866: // When the open causes a reset. ! 867: // ! 868: // A packet currently being sent. ! 869: // ! 870: // (Basically the above two mean any time the open has left ! 871: // some processing around to be accomplished later.) ! 872: // ! 873: // This field should only be accessed when the adapter lock is held. ! 874: // ! 875: UINT References; ! 876: ! 877: // ! 878: // Minimum Number of bytes for a lookahead. ! 879: // ! 880: UINT LookAhead; ! 881: ! 882: // ! 883: // A flag indicating that the open has pended. ! 884: // ! 885: BOOLEAN OpenPending; ! 886: ! 887: // ! 888: // A flag indicating that this binding is in the process of closing. ! 889: // ! 890: BOOLEAN BindingShuttingDown; ! 891: ! 892: ! 893: // ! 894: // A bogus NdisRequest to queue operations during a close. ! 895: // ! 896: NDIS_REQUEST CloseRequestChangeFilter; ! 897: NDIS_REQUEST CloseRequestChangeAddress; ! 898: NDIS_REQUEST CloseRequestChangeGroupAddress; ! 899: ! 900: } IBMTOK_OPEN,*PIBMTOK_OPEN; ! 901: ! 902: ! 903: // ! 904: // procedures which do error logging ! 905: // ! 906: ! 907: typedef enum _IBMTOK_PROC_ID{ ! 908: registerAdapter, ! 909: openAdapter, ! 910: hardwareDetails, ! 911: handleResetStaging, ! 912: handleSrbSsb, ! 913: startPendQueueOp, ! 914: finishPendQueueOp, ! 915: handleDeferred, ! 916: ibmtokDpc ! 917: }IBMTOK_PROC_ID; ! 918: ! 919: // ! 920: // Error log values ! 921: // ! 922: ! 923: #define IBMTOK_ERRMSG_NOT_FOUND (ULONG)0x01 ! 924: #define IBMTOK_ERRMSG_CREATE_DB (ULONG)0x02 ! 925: #define IBMTOK_ERRMSG_INIT_INTERRUPT (ULONG)0x03 ! 926: #define IBMTOK_ERRMSG_OPEN_DB (ULONG)0x04 ! 927: #define IBMTOK_ERRMSG_ALLOC_MEM (ULONG)0x05 ! 928: #define IBMTOK_ERRMSG_UNSUPPORTED_RAM (ULONG)0x06 ! 929: #define IBMTOK_ERRMSG_BRINGUP_FAILURE (ULONG)0x07 ! 930: #define IBMTOK_ERRMSG_INVALID_CMD (ULONG)0x08 ! 931: #define IBMTOK_ERRMSG_BAD_OP (ULONG)0x09 ! 932: #define IBMTOK_ERRMSG_INVALID_STATUS (ULONG)0x0A ! 933: #define IBMTOK_ERRMSG_INVALID_STATE (ULONG)0x0B ! 934: #define IBMTOK_ERRMSG_ISRP_LOW_ERROR (ULONG)0x0C ! 935: ! 936: // ! 937: // This macro returns a pointer to a PIBMTOK_OPEN given a MacBindingHandle. ! 938: // ! 939: #define PIBMTOK_OPEN_FROM_BINDING_HANDLE(Handle) \ ! 940: ((PIBMTOK_OPEN)((PVOID)Handle)) ! 941: ! 942: ! 943: // ! 944: // This macro returns a NDIS_HANDLE from a PIBMTOK_OPEN ! 945: // ! 946: #define BINDING_HANDLE_FROM_PIBMTOK_OPEN(Open) \ ! 947: ((NDIS_HANDLE)((PVOID)Open)) ! 948: ! 949: ! 950: // ! 951: // This macro will act a "epilogue" to every routine in the ! 952: // *interface*. It will check whether there any requests needed ! 953: // to defer there processing. It will also decrement the reference ! 954: // count on the adapter. If the reference count is zero and there ! 955: // is deferred work to do it will insert the interrupt processing ! 956: // routine in the DPC queue. ! 957: // ! 958: // Note that we don't need to include checking for blocked receives ! 959: // since blocked receives imply that there will eventually be an ! 960: // interrupt. ! 961: // ! 962: // NOTE: This macro assumes that it is called with the lock acquired. ! 963: // ! 964: #define IBMTOK_DO_DEFERRED(Adapter) \ ! 965: { \ ! 966: PIBMTOK_ADAPTER _A = (Adapter); \ ! 967: _A->References--; \ ! 968: if ((!_A->References) && \ ! 969: (_A->ResetInProgress || \ ! 970: (!IsListEmpty(&_A->CloseList)))) { \ ! 971: IbmtokHandleDeferred(_A); \ ! 972: NdisReleaseSpinLock(&_A->Lock); \ ! 973: } else { \ ! 974: NdisReleaseSpinLock(&_A->Lock); \ ! 975: } \ ! 976: } ! 977: ! 978: ! 979: //++ ! 980: // ! 981: // VOID ! 982: // SET_INTERRUPT_RESET_FLAG( ! 983: // IN PIBMTOK_ADAPTER Adapter, ! 984: // ) ! 985: // ! 986: // ! 987: // Routine Description: ! 988: // ! 989: // This routine uses NdisSynchronizeWithInterrupt to call the ! 990: // IbmtokSynchSetReset, which sets the ResetInterruptAllowed ! 991: // flag in the adapter structure. This is set after the ! 992: // adapter is reset to allow the interrupt indicating the ! 993: // end of the reset to come through (since all others ! 994: // should be blocked during the reset). ! 995: // ! 996: // Arguments: ! 997: // ! 998: // Adapter - The adapter to set the flag for. ! 999: // ! 1000: // Return Value: ! 1001: // ! 1002: // None. ! 1003: // ! 1004: //-- ! 1005: ! 1006: #define SET_INTERRUPT_RESET_FLAG(A) \ ! 1007: { \ ! 1008: PIBMTOK_ADAPTER _A = A; \ ! 1009: NdisSynchronizeWithInterrupt( \ ! 1010: &_A->Interrupt, \ ! 1011: (PVOID) IbmtokSynchSetReset, \ ! 1012: (PVOID)_A \ ! 1013: ); \ ! 1014: } ! 1015: ! 1016: ! 1017: // ! 1018: // This macro is to clear the SRB/SSB and ARB/ASB bits ! 1019: // used by the interrupt handlers. ! 1020: // ! 1021: ! 1022: #define CLEAR_ISRP_BITS(A) \ ! 1023: { \ ! 1024: PIBMTOK_ADAPTER _A = A; \ ! 1025: NdisSynchronizeWithInterrupt( \ ! 1026: &_A->Interrupt, \ ! 1027: (PVOID) IbmtokSynchClearIsrpBits, \ ! 1028: (PVOID)_A \ ! 1029: ); \ ! 1030: } ! 1031: ! 1032: ! 1033: ! 1034: // ! 1035: // VOID ! 1036: // IbmtokProcessSrbRequests( ! 1037: // IN PIBMTOK_ADAPTER Adapter ! 1038: // ) ! 1039: // /*++ ! 1040: // ! 1041: // Routine Description: ! 1042: // ! 1043: // Check if the SRB is available, if so queue the next ! 1044: // request on it. Preferably, it is called when it is known ! 1045: // that there is something on the queue. ! 1046: // ! 1047: // NOTE: THIS IS CALLED WITH THE LOCK HELD!!! ! 1048: // ! 1049: // NOTE: THIS MUST BE CALLED WITH Adapter->SrbAvailable == TRUE !!!!! ! 1050: // ! 1051: // Arguments: ! 1052: // ! 1053: // Adapter - The Adapter to process interrupts for. ! 1054: // ! 1055: // Return Value: ! 1056: // ! 1057: // None. ! 1058: // ! 1059: // --*/ ! 1060: // ! 1061: ! 1062: #define IbmtokProcessSrbRequests(_Adapter) \ ! 1063: { \ ! 1064: if (_Adapter->SrbAvailable) { \ ! 1065: (_Adapter)->SrbAvailable = FALSE;\ ! 1066: SetupSrbCommand(_Adapter); \ ! 1067: } \ ! 1068: } ! 1069: ! 1070: ! 1071: // VOID ! 1072: // PutPacketInCorrelatorArray( ! 1073: // IN PIBMTOK_ADAPTER Adapter, ! 1074: // IN PNDIS_PACKET Packet ! 1075: // ) ! 1076: // ! 1077: // /*++ ! 1078: // ! 1079: // Routine Description: ! 1080: // ! 1081: // This inserts a packet in the correlator array, based ! 1082: // on the value of its command correlator. ! 1083: // ! 1084: // Arguments: ! 1085: // ! 1086: // Adapter - The adapter that this packet is coming through. ! 1087: // ! 1088: // Packet - The packet that is to be inserted. ! 1089: // ! 1090: // Return Value: ! 1091: // ! 1092: // None. ! 1093: // ! 1094: // --*/ ! 1095: // ! 1096: #define PutPacketInCorrelatorArray( _Adapter, _Packet) \ ! 1097: { \ ! 1098: PIBMTOK_RESERVED _Reserved = PIBMTOK_RESERVED_FROM_PACKET(_Packet); \ ! 1099: ASSERT(_Reserved->CorrelatorAssigned); \ ! 1100: ASSERT((_Adapter)->CorrelatorArray[_Reserved->CommandCorrelator] == (PNDIS_PACKET)NULL); \ ! 1101: (_Adapter)->CorrelatorArray[_Reserved->CommandCorrelator] = (_Packet); \ ! 1102: } ! 1103: ! 1104: ! 1105: ! 1106: // STATIC ! 1107: // VOID ! 1108: // RemovePacketFromCorrelatorArray( ! 1109: // IN PIBMTOK_ADAPTER Adapter, ! 1110: // IN PNDIS_PACKET Packet ! 1111: // ) ! 1112: // ! 1113: // /*++ ! 1114: // ! 1115: // Routine Description: ! 1116: // ! 1117: // This deletes a packet in the correlator array, based ! 1118: // on the value of its command correlator. ! 1119: // ! 1120: // Arguments: ! 1121: // ! 1122: // Adapter - The adapter that this packet is coming through. ! 1123: // ! 1124: // Packet - The packet that is to be removed. ! 1125: // ! 1126: // Return Value: ! 1127: // ! 1128: // None. ! 1129: // ! 1130: // --*/ ! 1131: // ! 1132: #define RemovePacketFromCorrelatorArray(_Adapter, _Packet) \ ! 1133: { \ ! 1134: PIBMTOK_RESERVED _Reserved = PIBMTOK_RESERVED_FROM_PACKET(_Packet); \ ! 1135: ASSERT(_Reserved->CorrelatorAssigned); \ ! 1136: _Reserved->CorrelatorAssigned = FALSE; \ ! 1137: (_Adapter)->CorrelatorArray[_Reserved->CommandCorrelator] = (PNDIS_PACKET)NULL; \ ! 1138: } ! 1139: ! 1140: ! 1141: ! 1142: ! 1143: ! 1144: // ! 1145: // We define the external interfaces to the ibmtok driver. ! 1146: // These routines are only external to permit separate ! 1147: // compilation. Given a truely fast compiler they could ! 1148: // all reside in a single file and be static. ! 1149: // ! 1150: ! 1151: ! 1152: extern ! 1153: VOID ! 1154: IbmtokAdjustMaxLookAhead( ! 1155: IN PIBMTOK_ADAPTER Adapter ! 1156: ); ! 1157: ! 1158: ! 1159: extern ! 1160: VOID ! 1161: IbmtokDPC( ! 1162: IN PVOID SystemSpecific1, ! 1163: IN PVOID Context, ! 1164: IN PVOID SystemArgument1, ! 1165: IN PVOID SystemArgument2 ! 1166: ); ! 1167: ! 1168: extern ! 1169: VOID ! 1170: SetupSrbCommand( ! 1171: IN PIBMTOK_ADAPTER Adapter ! 1172: ); ! 1173: ! 1174: extern ! 1175: VOID ! 1176: IbmtokWakeUpDpc( ! 1177: IN PVOID SystemSpecific1, ! 1178: IN PVOID Context, ! 1179: IN PVOID SystemArgument1, ! 1180: IN PVOID SystemArgument2 ! 1181: ); ! 1182: ! 1183: extern ! 1184: BOOLEAN ! 1185: IbmtokISR( ! 1186: IN PVOID Context ! 1187: ); ! 1188: ! 1189: extern ! 1190: VOID ! 1191: IbmtokHandleDeferred( ! 1192: IN PIBMTOK_ADAPTER Adapter ! 1193: ); ! 1194: ! 1195: extern ! 1196: NDIS_STATUS ! 1197: IbmtokSetPacketFilter( ! 1198: IN PIBMTOK_ADAPTER Adapter, ! 1199: IN PIBMTOK_OPEN Open, ! 1200: IN PNDIS_REQUEST NdisRequest, ! 1201: IN UINT PacketFilter ! 1202: ); ! 1203: ! 1204: extern ! 1205: NDIS_STATUS ! 1206: IbmtokChangeFunctionalAddress( ! 1207: IN PIBMTOK_ADAPTER Adapter, ! 1208: IN PIBMTOK_OPEN Open, ! 1209: IN PNDIS_REQUEST NdisRequest, ! 1210: IN PUCHAR Address ! 1211: ); ! 1212: ! 1213: extern ! 1214: NDIS_STATUS ! 1215: IbmtokFillInGlobalData( ! 1216: IN PIBMTOK_ADAPTER Adapter, ! 1217: IN PNDIS_REQUEST NdisRequest ! 1218: ); ! 1219: ! 1220: ! 1221: extern ! 1222: VOID ! 1223: IbmtokForceAdapterInterrupt( ! 1224: IN PIBMTOK_ADAPTER Adapter ! 1225: ); ! 1226: ! 1227: extern ! 1228: VOID ! 1229: IbmtokSetupForReset( ! 1230: IN PIBMTOK_ADAPTER Adapter, ! 1231: IN PIBMTOK_OPEN Open ! 1232: ); ! 1233: ! 1234: extern ! 1235: VOID ! 1236: IbmtokStartAdapterReset( ! 1237: IN PIBMTOK_ADAPTER Adapter ! 1238: ); ! 1239: ! 1240: extern ! 1241: VOID ! 1242: IbmtokFinishAdapterReset( ! 1243: IN PIBMTOK_ADAPTER Adapter ! 1244: ); ! 1245: ! 1246: extern ! 1247: BOOLEAN ! 1248: IbmtokSynchSetReset( ! 1249: IN PVOID Context ! 1250: ); ! 1251: ! 1252: extern ! 1253: VOID ! 1254: IbmtokAbortPending( ! 1255: IN PIBMTOK_ADAPTER Adapter, ! 1256: IN NDIS_STATUS AbortStatus ! 1257: ); ! 1258: ! 1259: extern ! 1260: VOID ! 1261: IbmtokAbortSends( ! 1262: IN PIBMTOK_ADAPTER Adapter, ! 1263: IN NDIS_STATUS AbortStatus ! 1264: ); ! 1265: ! 1266: extern ! 1267: BOOLEAN ! 1268: IbmtokSynchClearIsrpBits( ! 1269: IN PVOID Context ! 1270: ); ! 1271: ! 1272: extern ! 1273: NDIS_STATUS ! 1274: IbmtokTransferData( ! 1275: IN NDIS_HANDLE MacBindingHandle, ! 1276: IN NDIS_HANDLE MacReceiveContext, ! 1277: IN UINT ByteOffset, ! 1278: IN UINT BytesToTransfer, ! 1279: OUT PNDIS_PACKET Packet, ! 1280: OUT PUINT BytesTransferred ! 1281: ); ! 1282: ! 1283: extern ! 1284: NDIS_STATUS ! 1285: IbmtokSend( ! 1286: IN NDIS_HANDLE MacBindingHandle, ! 1287: IN PNDIS_PACKET Packet ! 1288: ); ! 1289: ! 1290: extern ! 1291: VOID ! 1292: IbmtokCopyFromPacketToBuffer( ! 1293: IN PNDIS_PACKET Packet, ! 1294: IN UINT Offset, ! 1295: IN UINT BytesToCopy, ! 1296: OUT PCHAR Buffer, ! 1297: OUT PUINT BytesCopied ! 1298: ); ! 1299: ! 1300: extern ! 1301: VOID ! 1302: IbmtokCopyFromBufferToPacket( ! 1303: IN PCHAR Buffer, ! 1304: IN UINT BytesToCopy, ! 1305: IN PNDIS_PACKET Packet, ! 1306: IN UINT Offset, ! 1307: OUT PUINT BytesCopied ! 1308: ); ! 1309: ! 1310: extern ! 1311: VOID ! 1312: IbmtokCopyFromPacketToPacket( ! 1313: IN PNDIS_PACKET Destination, ! 1314: IN UINT DestinationOffset, ! 1315: IN UINT BytesToCopy, ! 1316: IN PNDIS_PACKET Source, ! 1317: IN UINT SourceOffset, ! 1318: OUT PUINT BytesCopied ! 1319: ); ! 1320: ! 1321: #endif // _IBMTOKSFT_ ! 1322:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.