|
|
1.1 root 1: /*++
2:
3: Copyright (c) 1992 Microsoft Corporation
4:
5: Module Name:
6:
7: deteisa.c
8:
9: Abstract:
10:
11: This is the main file for the autodetection DLL for all the EISA adapters
12: which MS is shipping with Windows NT.
13:
14:
15: --*/
16:
17: #include <ntddk.h>
18: #include <ntddnetd.h>
19:
20: #include <windef.h>
21: #include <winerror.h>
22:
23: #include <stdio.h>
24: #include <stdlib.h>
25: #include <string.h>
26: #include "detect.h"
27:
28:
29: // Prototype "borrowed" from WINUSER.H
30: extern int WINAPIV wsprintfW(LPWSTR, LPCWSTR, ...);
31: // Prototype "borrowed" from WINBASE.H
32: VOID WINAPI Sleep( DWORD dwMilliseconds );
33:
34: //
35: // Individual card detection routines
36: //
37:
38:
39: //
40: // Helper functions
41: //
42:
43: ULONG
44: FindEisaCard(
45: IN ULONG AdapterNumber,
46: IN ULONG BusNumber,
47: IN BOOLEAN First,
48: IN ULONG CompressedId,
49: OUT PULONG Confidence
50: );
51:
52: #ifdef WORKAROUND
53:
54: UCHAR EisaFirstTime = 1;
55:
56: //
57: // List of all the adapters supported in this file, this cannot be > 256
58: // because of the way tokens are generated.
59: //
60: //
61: // NOTE : If you change the index of an adapter, be sure the change it in
62: // EisaQueryCfgHandler(), EisaFirstNextHandler() and EisaVerifyCfgHandler() as
63: // well!
64: //
65:
66: static ADAPTER_INFO Adapters[] = {
67:
68: {
69: 1000,
70: L"NE3200",
71: L"SLOTNUMBER 1 100 ",
72: NULL,
73: 999
74:
75: },
76:
77: {
78: 1100,
79: L"DEC422",
80: L"SLOTNUMBER 1 100 ",
81: NULL,
82: 999
83:
84: },
85:
86: {
87: 1200,
88: L"P1990",
89: L"SLOTNUMBER 1 100 ",
90: NULL,
91: 999
92:
93: },
94:
95: {
96: 1300,
97: L"NETFLX",
98: L"SLOTNUMBER 1 100 ",
99: NULL,
100: 999
101:
102: },
103:
104: {
105: 1400,
106: L"CPQTOK",
107: L"SLOTNUMBER 1 100 ",
108: NULL,
109: 999
110:
111: }
112: };
113:
114: #else
115:
116: //
117: // List of all the adapters supported in this file, this cannot be > 256
118: // because of the way tokens are generated.
119: //
120: //
121: // NOTE : If you change the index of an adapter, be sure the change it in
122: // EisaQueryCfgHandler(), EisaFirstNextHandler() and EisaVerifyCfgHandler() as
123: // well!
124: //
125:
126: static ADAPTER_INFO Adapters[] = {
127:
128: {
129: 1000,
130: L"NE3200",
131: L"SLOTNUMBER\0001\000100\0",
132: NULL,
133: 999
134:
135: },
136:
137: {
138: 1100,
139: L"DEC422",
140: L"SLOTNUMBER\0001\000100\0",
141: NULL,
142: 999
143:
144: },
145:
146: {
147: 1200,
148: L"P1990",
149: L"SLOTNUMBER\0001\000100\0",
150: NULL,
151: 999
152:
153: },
154:
155: {
156: 1300,
157: L"NETFLEX",
158: L"SLOTNUMBER\0001\000100\0",
159: NULL,
160: 999
161:
162: },
163:
164: {
165: 1400,
166: L"CPQTOK",
167: L"SLOTNUMBER\0001\000100\0",
168: NULL,
169: 999
170:
171: }
172:
173: };
174:
175: #endif
176:
177: //
178: // Structure for holding state of a search
179: //
180:
181: typedef struct _SEARCH_STATE {
182:
183: ULONG SlotNumber;
184:
185: } SEARCH_STATE, *PSEARCH_STATE;
186:
187:
188: //
189: // This is an array of search states. We need one state for each type
190: // of adapter supported.
191: //
192:
193: static SEARCH_STATE SearchStates[sizeof(Adapters) / sizeof(ADAPTER_INFO)] = {0};
194:
195:
196: //
197: // Structure for holding a particular adapter's complete information
198: //
199: typedef struct _EISA_ADAPTER {
200:
201: LONG CardType;
202: INTERFACE_TYPE InterfaceType;
203: ULONG BusNumber;
204: ULONG SlotNumber;
205:
206: } EISA_ADAPTER, *PEISA_ADAPTER;
207:
208:
209: extern
210: LONG
211: EisaIdentifyHandler(
212: IN LONG Index,
213: IN WCHAR * Buffer,
214: IN LONG BuffSize
215: )
216:
217: /*++
218:
219: Routine Description:
220:
221: This routine returns information about the netcards supported by
222: this file.
223:
224: Arguments:
225:
226: Index - The index of the netcard being address. The first
227: cards information is at index 1000, the second at 1100, etc.
228:
229: Buffer - Buffer to store the result into.
230:
231: BuffSize - Number of bytes in Buffer
232:
233: Return Value:
234:
235: 0 if nothing went wrong, else the appropriate WINERROR.H value.
236:
237: --*/
238:
239:
240: {
241: LONG NumberOfAdapters;
242: LONG Code = Index % 100;
243: LONG Length;
244: LONG i;
245:
246: NumberOfAdapters = sizeof(Adapters) / sizeof(ADAPTER_INFO);
247:
248: #ifdef WORKAROUND
249:
250: //
251: // We need to convert unicode spaces into unicode NULLs.
252: //
253:
254: if (EisaFirstTime) {
255:
256: EisaFirstTime = 0;
257:
258: for (i = 0; i < NumberOfAdapters; i++) {
259:
260: Length = UnicodeStrLen(Adapters[i].Parameters);
261:
262: for (; Length > 0; Length--) {
263:
264: if (Adapters[i].Parameters[Length] == L' ') {
265:
266: Adapters[i].Parameters[Length] = UNICODE_NULL;
267:
268: }
269:
270: }
271:
272: }
273:
274: }
275:
276: #endif
277:
278: Index = Index - Code;
279:
280: if (((Index / 100) - 10) < NumberOfAdapters) {
281:
282: //
283: // Find the correct adapter ID
284: //
285:
286: for (i=0; i < NumberOfAdapters; i++) {
287:
288: if (Adapters[i].Index == Index) {
289:
290: switch (Code) {
291:
292: case 0:
293:
294: //
295: // Find the string length
296: //
297:
298: Length = UnicodeStrLen(Adapters[i].InfId);
299:
300: Length ++;
301:
302: if (BuffSize < Length) {
303:
304: return(ERROR_INSUFFICIENT_BUFFER);
305:
306: }
307:
308: memcpy((PVOID)Buffer, Adapters[i].InfId, Length * sizeof(WCHAR));
309: break;
310:
311: case 3:
312:
313: //
314: // Maximum value is 1000
315: //
316:
317: if (BuffSize < 5) {
318:
319: return(ERROR_INSUFFICIENT_BUFFER);
320:
321: }
322:
323: wsprintfW((PVOID)Buffer, L"%d", Adapters[i].SearchOrder);
324:
325: break;
326:
327: default:
328:
329: return(ERROR_INVALID_PARAMETER);
330:
331: }
332:
333: return(0);
334:
335: }
336:
337: }
338:
339: return(ERROR_INVALID_PARAMETER);
340:
341: }
342:
343: return(ERROR_NO_MORE_ITEMS);
344:
345: }
346:
347:
348: extern
349: LONG
350: EisaFirstNextHandler(
351: IN LONG NetcardId,
352: IN INTERFACE_TYPE InterfaceType,
353: IN ULONG BusNumber,
354: IN BOOL First,
355: OUT PVOID *Token,
356: OUT LONG *Confidence
357: )
358:
359: /*++
360:
361: Routine Description:
362:
363: This routine finds the instances of a physical adapter identified
364: by the NetcardId.
365:
366: Arguments:
367:
368: NetcardId - The index of the netcard being address. The first
369: cards information is id 1000, the second id 1100, etc.
370:
371: InterfaceType - Microchannel
372:
373: BusNumber - The bus number of the bus to search.
374:
375: First - TRUE is we are to search for the first instance of an
376: adapter, FALSE if we are to continue search from a previous stopping
377: point.
378:
379: Token - A pointer to a handle to return to identify the found
380: instance
381:
382: Confidence - A pointer to a long for storing the confidence factor
383: that the card exists.
384:
385: Return Value:
386:
387: 0 if nothing went wrong, else the appropriate WINERROR.H value.
388:
389: --*/
390:
391: {
392: ULONG CompressedId;
393: ULONG ReturnValue;
394:
395: if (InterfaceType != Eisa) {
396:
397: *Confidence = 0;
398: return(0);
399:
400: }
401:
402: //
403: // Get CompressedId
404: //
405:
406: switch (NetcardId) {
407:
408: //
409: // NE3200
410: //
411:
412: case 1000:
413:
414: CompressedId = 0x07CC3A;
415: break;
416:
417: //
418: // DEC422
419: //
420:
421: case 1100:
422:
423: CompressedId = 0x42A310;
424: break;
425:
426: //
427: // PROTEON 1990
428: //
429:
430: case 1200:
431:
432: CompressedId = 0x604F42;
433: break;
434:
435: //
436: // NET FLEX
437: //
438:
439: case 1300:
440:
441: CompressedId = 0x61110E;
442: break;
443:
444: //
445: // COMPAQ Jupiter board
446: //
447:
448: case 1400:
449:
450: CompressedId = 0x60110E;
451: break;
452:
453: default:
454:
455: return(ERROR_INVALID_PARAMETER);
456:
457: }
458:
459: //
460: // Call FindFirst Routine
461: //
462:
463: ReturnValue = FindEisaCard(
464: (ULONG)((NetcardId - 1000) / 100),
465: BusNumber,
466: (BOOLEAN)First,
467: CompressedId,
468: Confidence
469: );
470:
471: if (ReturnValue == 0) {
472:
473: //
474: // In this module I use the token as follows: Remember that
475: // the token can only be 2 bytes long (the low 2) because of
476: // the interface to the upper part of this DLL.
477: //
478: // The rest of the high byte is the the bus number.
479: // The low byte is the driver index number into Adapters.
480: //
481: // NOTE: This presumes that there are < 129 buses in the
482: // system. Is this reasonable?
483: //
484:
485: *Token = (PVOID)((BusNumber & 0x7F) << 8);
486:
487: *Token = (PVOID)(((ULONG)*Token) | ((NetcardId - 1000) / 100));
488:
489: }
490:
491: return(ReturnValue);
492:
493: }
494:
495: extern
496: LONG
497: EisaOpenHandleHandler(
498: IN PVOID Token,
499: OUT PVOID *Handle
500: )
501:
502: /*++
503:
504: Routine Description:
505:
506: This routine takes a token returned by FirstNext and converts it
507: into a permanent handle.
508:
509: Arguments:
510:
511: Token - The token.
512:
513: Handle - A pointer to the handle, so we can store the resulting
514: handle.
515:
516: Return Value:
517:
518: 0 if nothing went wrong, else the appropriate WINERROR.H value.
519:
520: --*/
521:
522: {
523: PEISA_ADAPTER Adapter;
524: LONG AdapterNumber;
525: ULONG BusNumber;
526: INTERFACE_TYPE InterfaceType;
527:
528: //
529: // Get info from the token
530: //
531:
532: InterfaceType = Eisa;
533:
534: BusNumber = (ULONG)(((ULONG)Token >> 8) & 0x7F);
535:
536: AdapterNumber = ((ULONG)Token) & 0xFF;
537:
538: //
539: // Store information
540: //
541:
542: Adapter = (PEISA_ADAPTER)DetectAllocateHeap(
543: sizeof(EISA_ADAPTER)
544: );
545:
546: if (Adapter == NULL) {
547:
548: return(ERROR_NOT_ENOUGH_MEMORY);
549:
550: }
551:
552: //
553: // Copy across address
554: //
555:
556: Adapter->SlotNumber = SearchStates[(ULONG)AdapterNumber].SlotNumber;
557: Adapter->CardType = Adapters[AdapterNumber].Index;
558: Adapter->InterfaceType = InterfaceType;
559: Adapter->BusNumber = BusNumber;
560:
561: *Handle = (PVOID)Adapter;
562:
563: return(0);
564: }
565:
566: LONG
567: EisaCreateHandleHandler(
568: IN LONG NetcardId,
569: IN INTERFACE_TYPE InterfaceType,
570: IN ULONG BusNumber,
571: OUT PVOID *Handle
572: )
573:
574: /*++
575:
576: Routine Description:
577:
578: This routine is used to force the creation of a handle for cases
579: where a card is not found via FirstNext, but the user says it does
580: exist.
581:
582: Arguments:
583:
584: NetcardId - The id of the card to create the handle for.
585:
586: InterfaceType - Microchannel
587:
588: BusNumber - The bus number of the bus in the system.
589:
590: Handle - A pointer to the handle, for storing the resulting handle.
591:
592: Return Value:
593:
594: 0 if nothing went wrong, else the appropriate WINERROR.H value.
595:
596: --*/
597:
598: {
599: PEISA_ADAPTER Adapter;
600: LONG NumberOfAdapters;
601: LONG i;
602:
603: if (InterfaceType != Eisa) {
604:
605: return(ERROR_INVALID_PARAMETER);
606:
607: }
608:
609: NumberOfAdapters = sizeof(Adapters) / sizeof(ADAPTER_INFO);
610:
611: for (i=0; i < NumberOfAdapters; i++) {
612:
613: if (Adapters[i].Index == NetcardId) {
614:
615: //
616: // Store information
617: //
618:
619: Adapter = (PEISA_ADAPTER)DetectAllocateHeap(
620: sizeof(EISA_ADAPTER)
621: );
622:
623: if (Adapter == NULL) {
624:
625: return(ERROR_NOT_ENOUGH_MEMORY);
626:
627: }
628:
629: //
630: // Copy across memory address
631: //
632:
633: Adapter->SlotNumber = 1;
634: Adapter->CardType = NetcardId;
635: Adapter->InterfaceType = InterfaceType;
636: Adapter->BusNumber = BusNumber;
637:
638: *Handle = (PVOID)Adapter;
639:
640: return(0);
641:
642: }
643:
644: }
645:
646: return(ERROR_INVALID_PARAMETER);
647: }
648:
649: extern
650: LONG
651: EisaCloseHandleHandler(
652: IN PVOID Handle
653: )
654:
655: /*++
656:
657: Routine Description:
658:
659: This frees any resources associated with a handle.
660:
661: Arguments:
662:
663: Handle - The handle.
664:
665: Return Value:
666:
667: 0 if nothing went wrong, else the appropriate WINERROR.H value.
668:
669: --*/
670:
671: {
672: DetectFreeHeap(Handle);
673:
674: return(0);
675: }
676:
677: LONG
678: EisaQueryCfgHandler(
679: IN PVOID Handle,
680: OUT WCHAR *Buffer,
681: IN LONG BuffSize
682: )
683:
684: /*++
685:
686: Routine Description:
687:
688: This routine calls the appropriate driver's query config handler to
689: get the parameters for the adapter associated with the handle.
690:
691: Arguments:
692:
693: Handle - The handle.
694:
695: Buffer - The resulting parameter list.
696:
697: BuffSize - Length of the given buffer in WCHARs.
698:
699: Return Value:
700:
701: 0 if nothing went wrong, else the appropriate WINERROR.H value.
702:
703: --*/
704:
705: {
706: PEISA_ADAPTER Adapter = (PEISA_ADAPTER)(Handle);
707: LONG OutputLengthLeft = BuffSize;
708: LONG CopyLength;
709: ULONG CompressedId;
710: PVOID BusHandle;
711: ULONG ReturnValue;
712: ULONG Confidence;
713:
714: ULONG StartPointer = (ULONG)Buffer;
715:
716: if (Adapter->InterfaceType != Eisa) {
717:
718: return(ERROR_INVALID_PARAMETER);
719:
720: }
721:
722: //
723: // Verify the SlotNumber
724: //
725:
726: if (!GetEisaKey(Adapter->BusNumber, &BusHandle)) {
727:
728: return(ERROR_INVALID_PARAMETER);
729:
730: }
731:
732: if (!GetEisaCompressedId(
733: BusHandle,
734: Adapter->SlotNumber,
735: &CompressedId
736: )) {
737:
738: //
739: // Fail
740: //
741:
742: return(ERROR_INVALID_PARAMETER);
743:
744: }
745:
746: //
747: // Verify ID
748: //
749:
750: ReturnValue = ERROR_INVALID_PARAMETER;
751:
752: switch (Adapter->CardType) {
753:
754: //
755: // NE3200
756: //
757:
758: case 1000:
759:
760: if (CompressedId == 0x07CC3A) {
761:
762: ReturnValue = 0;
763:
764: } else {
765:
766: CompressedId = 0x07CC3A;
767:
768: }
769: break;
770:
771: //
772: // DEC422
773: //
774:
775: case 1100:
776:
777: if (CompressedId == 0x42A310) {
778:
779: ReturnValue = 0;
780:
781: } else {
782:
783: CompressedId = 0x42A310;
784:
785: }
786: break;
787:
788: //
789: // PROTEON 1990
790: //
791:
792: case 1200:
793:
794: if (CompressedId == 0x604F42) {
795:
796: ReturnValue = 0;
797:
798: } else {
799:
800: CompressedId = 0x604F42;
801:
802: }
803: break;
804:
805: //
806: // NET FLEX
807: //
808:
809: case 1300:
810:
811: if (CompressedId == 0x61110E) {
812:
813: ReturnValue = 0;
814:
815: } else {
816:
817: CompressedId = 0x61110E;
818:
819: }
820: break;
821:
822: //
823: // COMPAQ Jupiter board
824: //
825:
826: case 1400:
827:
828: if (CompressedId == 0x60110E) {
829:
830: ReturnValue = 0;
831:
832: } else {
833:
834: CompressedId = 0x60110E;
835:
836: }
837: break;
838:
839: default:
840:
841: return(ERROR_INVALID_PARAMETER);
842:
843: }
844:
845:
846: if (ReturnValue != 0) {
847:
848: //
849: // Try to find it in another slot
850: //
851:
852: ReturnValue = FindEisaCard(
853: Adapter->CardType,
854: Adapter->BusNumber,
855: TRUE,
856: CompressedId,
857: &Confidence
858: );
859:
860: if (Confidence != 100) {
861:
862: //
863: // Confidence is not absolute -- we are out of here.
864: //
865:
866: return(ERROR_INVALID_PARAMETER);
867:
868: }
869:
870: Adapter->SlotNumber = SearchStates[(ULONG)Adapter->CardType].SlotNumber;
871:
872: }
873:
874: //
875: // Build resulting buffer
876: //
877:
878: //
879: // Put in SlotNumber
880: //
881:
882: //
883: // Copy in the title string
884: //
885:
886: CopyLength = UnicodeStrLen(SlotNumberString) + 1;
887:
888: if (OutputLengthLeft < CopyLength) {
889:
890: return(ERROR_INSUFFICIENT_BUFFER);
891:
892: }
893:
894: memcpy((PVOID)Buffer,
895: (PVOID)SlotNumberString,
896: (CopyLength * sizeof(WCHAR))
897: );
898:
899: Buffer = &(Buffer[CopyLength]);
900: OutputLengthLeft -= CopyLength;
901:
902: //
903: // Copy in the value
904: //
905:
906: if (OutputLengthLeft < 8) {
907:
908: return(ERROR_INSUFFICIENT_BUFFER);
909:
910: }
911:
912: CopyLength = wsprintfW(Buffer,L"0x%x",(ULONG)(Adapter->SlotNumber));
913:
914: if (CopyLength < 0) {
915:
916: return(ERROR_INSUFFICIENT_BUFFER);
917:
918: }
919:
920: CopyLength++; // Add in the \0
921:
922: Buffer = &(Buffer[CopyLength]);
923: OutputLengthLeft -= CopyLength;
924:
925: //
926: // Copy in final \0
927: //
928:
929: if (OutputLengthLeft < 1) {
930:
931: return(ERROR_INSUFFICIENT_BUFFER);
932:
933: }
934:
935: CopyLength = (ULONG)Buffer - StartPointer;
936: Buffer[CopyLength] = L'\0';
937:
938: return(0);
939: }
940:
941: extern
942: LONG
943: EisaVerifyCfgHandler(
944: IN PVOID Handle,
945: IN WCHAR *Buffer
946: )
947:
948: /*++
949:
950: Routine Description:
951:
952: This routine verifys that a given parameter list is complete and
953: correct for the adapter associated with the handle.
954:
955: Arguments:
956:
957: Handle - The handle.
958:
959: Buffer - The parameter list.
960:
961: Return Value:
962:
963: 0 if nothing went wrong, else the appropriate WINERROR.H value.
964:
965: --*/
966:
967: {
968: PEISA_ADAPTER Adapter = (PEISA_ADAPTER)(Handle);
969: WCHAR *Place;
970: ULONG CompressedId;
971: ULONG SlotNumber;
972: PVOID BusHandle;
973: BOOLEAN Found;
974:
975: if (Adapter->InterfaceType != Eisa) {
976:
977: return(ERROR_INVALID_DATA);
978:
979: }
980:
981: //
982: // Parse out the parameter.
983: //
984:
985: //
986: // Get the SlotNumber
987: //
988:
989: Place = FindParameterString(Buffer, SlotNumberString);
990:
991: if (Place == NULL) {
992:
993: return(ERROR_INVALID_DATA);
994:
995: }
996:
997: Place += UnicodeStrLen(SlotNumberString) + 1;
998:
999: //
1000: // Now parse the thing.
1001: //
1002:
1003: ScanForNumber(Place, &SlotNumber, &Found);
1004:
1005: if (Found == FALSE) {
1006:
1007: return(ERROR_INVALID_DATA);
1008:
1009: }
1010:
1011: //
1012: // Verify the SlotNumber
1013: //
1014:
1015: if (!GetEisaKey(Adapter->BusNumber, &BusHandle)) {
1016:
1017: return(ERROR_INVALID_DATA);
1018:
1019: }
1020:
1021: if (!GetEisaCompressedId(
1022: BusHandle,
1023: SlotNumber,
1024: &CompressedId
1025: )) {
1026:
1027: //
1028: // Fail
1029: //
1030:
1031: return(ERROR_INVALID_DATA);
1032:
1033: }
1034:
1035: //
1036: // Verify ID
1037: //
1038:
1039: switch (Adapter->CardType) {
1040:
1041: //
1042: // NE3200
1043: //
1044:
1045: case 1000:
1046:
1047: if (CompressedId != 0x07CC3A) {
1048:
1049: return(ERROR_INVALID_DATA);
1050:
1051: }
1052: break;
1053:
1054: //
1055: // DEC422
1056: //
1057:
1058: case 1100:
1059:
1060: if (CompressedId != 0x42A310) {
1061:
1062: return(ERROR_INVALID_DATA);
1063:
1064: }
1065: break;
1066:
1067: //
1068: // PROTEON 1990
1069: //
1070:
1071: case 1200:
1072:
1073: if (CompressedId != 0x604F42) {
1074:
1075: return(ERROR_INVALID_DATA);
1076:
1077: }
1078: break;
1079:
1080: //
1081: // NET FLEX
1082: //
1083:
1084: case 1300:
1085:
1086: if (CompressedId != 0x61110E) {
1087:
1088: return(ERROR_INVALID_DATA);
1089:
1090: }
1091: break;
1092:
1093: //
1094: // COMPAQ Jupiter Board
1095: //
1096:
1097: case 1400:
1098:
1099: if (CompressedId != 0x60110E) {
1100:
1101: return(ERROR_INVALID_DATA);
1102:
1103: }
1104: break;
1105:
1106: default:
1107:
1108: return(ERROR_INVALID_DATA);
1109:
1110: }
1111:
1112: return(0);
1113:
1114: }
1115:
1116: extern
1117: LONG
1118: EisaQueryMaskHandler(
1119: IN LONG NetcardId,
1120: OUT WCHAR *Buffer,
1121: IN LONG BuffSize
1122: )
1123:
1124: /*++
1125:
1126: Routine Description:
1127:
1128: This routine returns the parameter list information for a specific
1129: network card.
1130:
1131: Arguments:
1132:
1133: NetcardId - The id of the desired netcard.
1134:
1135: Buffer - The buffer for storing the parameter information.
1136:
1137: BuffSize - Length of Buffer in WCHARs.
1138:
1139: Return Value:
1140:
1141: 0 if nothing went wrong, else the appropriate WINERROR.H value.
1142:
1143: --*/
1144:
1145: {
1146: WCHAR *Result;
1147: LONG Length;
1148: LONG NumberOfAdapters;
1149: LONG i;
1150:
1151: //
1152: // Find the adapter
1153: //
1154:
1155: NumberOfAdapters = sizeof(Adapters) / sizeof(ADAPTER_INFO);
1156:
1157: for (i=0; i < NumberOfAdapters; i++) {
1158:
1159: if (Adapters[i].Index == NetcardId) {
1160:
1161: Result = Adapters[i].Parameters;
1162:
1163: //
1164: // Find the string length (Ends with 2 NULLs)
1165: //
1166:
1167: for (Length=0; ; Length++) {
1168:
1169: if (Result[Length] == L'\0') {
1170:
1171: ++Length;
1172:
1173: if (Result[Length] == L'\0') {
1174:
1175: break;
1176:
1177: }
1178:
1179: }
1180:
1181: }
1182:
1183: Length++;
1184:
1185: if (BuffSize < Length) {
1186:
1187: return(ERROR_NOT_ENOUGH_MEMORY);
1188:
1189: }
1190:
1191: memcpy((PVOID)Buffer, Result, Length * sizeof(WCHAR));
1192:
1193: return(0);
1194:
1195: }
1196:
1197: }
1198:
1199: return(ERROR_INVALID_PARAMETER);
1200:
1201: }
1202:
1203: extern
1204: LONG
1205: EisaParamRangeHandler(
1206: IN LONG NetcardId,
1207: IN WCHAR *Param,
1208: OUT LONG *Values,
1209: OUT LONG *BuffSize
1210: )
1211:
1212: /*++
1213:
1214: Routine Description:
1215:
1216: This routine returns a list of valid values for a given parameter name
1217: for a given card.
1218:
1219: Arguments:
1220:
1221: NetcardId - The Id of the card desired.
1222:
1223: Param - A WCHAR string of the parameter name to query the values of.
1224:
1225: Values - A pointer to a list of LONGs into which we store valid values
1226: for the parameter.
1227:
1228: BuffSize - At entry, the length of Values in LONGs. At exit, the
1229: number of LONGs stored in Values.
1230:
1231: Return Value:
1232:
1233: 0 if nothing went wrong, else the appropriate WINERROR.H value.
1234:
1235: --*/
1236:
1237: {
1238:
1239: *BuffSize = 0;
1240: return(0);
1241:
1242: }
1243:
1244: extern
1245: LONG
1246: EisaQueryParameterNameHandler(
1247: IN WCHAR *Param,
1248: OUT WCHAR *Buffer,
1249: IN LONG BufferSize
1250: )
1251:
1252: /*++
1253:
1254: Routine Description:
1255:
1256: Returns a localized, displayable name for a specific parameter. All the
1257: parameters that this file uses are define by MS, so no strings are
1258: needed here.
1259:
1260: Arguments:
1261:
1262: Param - The parameter to be queried.
1263:
1264: Buffer - The buffer to store the result into.
1265:
1266: BufferSize - The length of Buffer in WCHARs.
1267:
1268: Return Value:
1269:
1270: ERROR_INVALID_PARAMETER -- To indicate that the MS supplied strings
1271: should be used.
1272:
1273: --*/
1274:
1275: {
1276: return(ERROR_INVALID_PARAMETER);
1277: }
1278:
1279: ULONG
1280: FindEisaCard(
1281: IN ULONG AdapterNumber,
1282: IN ULONG BusNumber,
1283: IN BOOLEAN First,
1284: IN ULONG CompressedId,
1285: OUT PULONG Confidence
1286: )
1287:
1288: /*++
1289:
1290: Routine Description:
1291:
1292: This routine finds the instances of a physical adapter identified
1293: by the CompressedId.
1294:
1295: Arguments:
1296:
1297: AdapterNumber - The index into the global array of adapters for the card.
1298:
1299: BusNumber - The bus number of the bus to search.
1300:
1301: First - TRUE is we are to search for the first instance of an
1302: adapter, FALSE if we are to continue search from a previous stopping
1303: point.
1304:
1305: CompressedId - The EISA Compressed Id of the card.
1306:
1307: Confidence - A pointer to a long for storing the confidence factor
1308: that the card exists.
1309:
1310: Return Value:
1311:
1312: 0 if nothing went wrong, else the appropriate WINERROR.H value.
1313:
1314: --*/
1315:
1316: {
1317: PVOID BusHandle;
1318: ULONG TmpCompressedId;
1319:
1320: if (First) {
1321:
1322: SearchStates[AdapterNumber].SlotNumber = 1;
1323:
1324: } else {
1325:
1326: SearchStates[AdapterNumber].SlotNumber++;
1327:
1328: }
1329:
1330: if (!GetEisaKey(BusNumber, &BusHandle)) {
1331:
1332: return(ERROR_INVALID_PARAMETER);
1333:
1334: }
1335:
1336: while (TRUE) {
1337:
1338: if (!GetEisaCompressedId(BusHandle,
1339: SearchStates[AdapterNumber].SlotNumber,
1340: &TmpCompressedId)) {
1341:
1342: *Confidence = 0;
1343: return(0);
1344:
1345: }
1346:
1347: if (CompressedId == TmpCompressedId) {
1348:
1349: *Confidence = 100;
1350: return(0);
1351:
1352: }
1353:
1354: SearchStates[AdapterNumber].SlotNumber++;
1355:
1356: }
1357:
1358: DeleteEisaKey(BusHandle);
1359:
1360: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.