ReactOS 0.4.16-dev-2-g02a6913
hardware.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS ISA PnP Bus driver
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Hardware support code
5 * COPYRIGHT: Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
6 * Copyright 2020 Hervé Poussineau <hpoussin@reactos.org>
7 * Copyright 2021 Dmitry Borisov <di.sean@protonmail.com>
8 */
9
10#ifndef UNIT_TEST
11
12#include "isapnp.h"
13
14#define NDEBUG
15#include <debug.h>
16
17#ifdef _MSC_VER
18#pragma warning(disable:28138) /* ISA bus always uses hardcoded port addresses */
19#endif
20
21#endif /* UNIT_TEST */
22
23static
24inline
25VOID
28{
30}
31
32static
33inline
34VOID
37{
39}
40
41static
42inline
45 _In_ PUCHAR ReadDataPort)
46{
47 return READ_PORT_UCHAR(ReadDataPort);
48}
49
50static
51CODE_SEG("PAGE")
52VOID
56{
57 PAGED_CODE();
58
61}
62
63static
64inline
65VOID
69{
71 WriteByte(Address, Value >> 8);
72}
73
74static
75inline
76VOID
80{
82 WriteWord(Address, Value >> 16);
83}
84
85static
86CODE_SEG("PAGE")
89 _In_ PUCHAR ReadDataPort,
91{
92 PAGED_CODE();
93
95 return ReadData(ReadDataPort);
96}
97
98static
99inline
100USHORT
102 _In_ PUCHAR ReadDataPort,
104{
105 return ((ReadByte(ReadDataPort, Address) << 8) |
106 (ReadByte(ReadDataPort, Address + 1)));
107}
108
109static
110inline
111ULONG
113 _In_ PUCHAR ReadDataPort,
115{
116 return ((ReadWord(ReadDataPort, Address) << 16) |
117 (ReadWord(ReadDataPort, Address + 2)));
118}
119
120static
121inline
122VOID
124 _In_ PUCHAR ReadDataPort)
125{
126 WriteByte(ISAPNP_READPORT, (UCHAR)((ULONG_PTR)ReadDataPort >> 2));
127}
128
129static
130inline
131VOID
133{
135}
136
137static
138inline
139VOID
141{
143}
144
145static
146inline
147VOID
149 _In_ UCHAR Csn)
150{
152}
153
154static
155inline
156UCHAR
158 _In_ PUCHAR ReadDataPort)
159{
160 return ReadByte(ReadDataPort, ISAPNP_RESOURCEDATA);
161}
162
163static
164inline
165UCHAR
167 _In_ PUCHAR ReadDataPort)
168{
169 return ReadByte(ReadDataPort, ISAPNP_STATUS);
170}
171
172static
173inline
174VOID
176 _In_ UCHAR Csn)
177{
179}
180
181static
182inline
183VOID
185 _In_ UCHAR LogDev)
186{
188}
189
190static
191inline
192VOID
194 _In_ PUCHAR ReadDataPort,
195 _In_ UCHAR LogDev)
196{
198
200 ReadByte(ReadDataPort, ISAPNP_IORANGECHECK) & ~2);
201
203}
204
205static
206inline
207VOID
209 _In_ UCHAR LogDev)
210{
213}
214
215static
216inline
217USHORT
219 _In_ PUCHAR ReadDataPort,
221{
222 return ReadWord(ReadDataPort, ISAPNP_IOBASE(Index));
223}
224
225static
226inline
227UCHAR
229 _In_ PUCHAR ReadDataPort,
231{
232 return ReadByte(ReadDataPort, ISAPNP_IRQNO(Index)) & 0x0F;
233}
234
235static
236inline
237UCHAR
239 _In_ PUCHAR ReadDataPort,
241{
242 return ReadByte(ReadDataPort, ISAPNP_IRQTYPE(Index));
243}
244
245static
246inline
247UCHAR
249 _In_ PUCHAR ReadDataPort,
251{
252 return ReadByte(ReadDataPort, ISAPNP_DMACHANNEL(Index)) & 0x07;
253}
254
255static
256inline
257USHORT
259 _In_ PUCHAR ReadDataPort,
261{
262 return ReadWord(ReadDataPort, ISAPNP_MEMBASE(Index));
263}
264
265static
266inline
267UCHAR
269 _In_ PUCHAR ReadDataPort,
271{
272 return ReadByte(ReadDataPort, ISAPNP_MEMCONTROL(Index));
273}
274
275static
276inline
277USHORT
279 _In_ PUCHAR ReadDataPort,
281{
282 return ReadWord(ReadDataPort, ISAPNP_MEMLIMIT(Index));
283}
284
285static
286inline
287ULONG
289 _In_ PUCHAR ReadDataPort,
291{
292 return ReadDoubleWord(ReadDataPort, ISAPNP_MEMBASE32(Index));
293}
294
295static
296inline
297UCHAR
299 _In_ PUCHAR ReadDataPort,
301{
302 return ReadByte(ReadDataPort, ISAPNP_MEMCONTROL32(Index));
303}
304
305static
306inline
307ULONG
309 _In_ PUCHAR ReadDataPort,
311{
312 return ReadDoubleWord(ReadDataPort, ISAPNP_MEMLIMIT32(Index));
313}
314
315static
316inline
317UCHAR
319 _In_ UCHAR Lfsr,
320 _In_ UCHAR InputBit)
321{
322 UCHAR NextLfsr = Lfsr >> 1;
323
324 NextLfsr |= (((Lfsr ^ NextLfsr) ^ InputBit)) << 7;
325
326 return NextLfsr;
327}
328
329static
330CODE_SEG("PAGE")
331VOID
333{
334 UCHAR i, Lfsr;
335
336 PAGED_CODE();
337
338 WriteAddress(0x00);
339 WriteAddress(0x00);
340
341 Lfsr = ISAPNP_LFSR_SEED;
342 for (i = 0; i < 32; i++)
343 {
344 WriteAddress(Lfsr);
345 Lfsr = NextLFSR(Lfsr, 0);
346 }
347}
348
349static
350CODE_SEG("PAGE")
351UCHAR
353 _In_ PUCHAR ReadDataPort)
354{
355 UCHAR i;
356
357 PAGED_CODE();
358
359 for (i = 0; i < 20; i++)
360 {
361 if (ReadStatus(ReadDataPort) & 0x01)
362 return ReadResourceData(ReadDataPort);
363
365 }
366
367 return 0xFF;
368}
369
370static
371CODE_SEG("PAGE")
372VOID
374 _In_ PUCHAR ReadDataPort,
377{
378 USHORT i;
379
380 PAGED_CODE();
381
382 for (i = 0; i < Length; i++)
383 {
384 UCHAR Byte = PeekByte(ReadDataPort);
385
386 if (Buffer)
387 ((PUCHAR)Buffer)[i] = Byte;
388 }
389}
390
391static
392CODE_SEG("PAGE")
393UCHAR
396{
397 UCHAR i, j, Lfsr;
398
399 PAGED_CODE();
400
401 Lfsr = ISAPNP_LFSR_SEED;
402 for (i = 0; i < FIELD_OFFSET(ISAPNP_IDENTIFIER, Checksum); i++)
403 {
405
406 for (j = 0; j < RTL_BITS_OF(Byte); j++)
407 {
408 Lfsr = NextLFSR(Lfsr, Byte);
409 Byte >>= 1;
410 }
411 }
412
413 return Lfsr;
414}
415
416static
417CODE_SEG("PAGE")
418VOID
421 _In_ USHORT CompressedData)
422{
423 PAGED_CODE();
424
425 Buffer[0] = ((CompressedData >> 2) & 0x1F) + 'A' - 1;
426 Buffer[1] = (((CompressedData & 0x3) << 3) | ((CompressedData >> 13) & 0x7)) + 'A' - 1;
427 Buffer[2] = ((CompressedData >> 8) & 0x1F) + 'A' - 1;
428}
429
430static
431CODE_SEG("PAGE")
434 _In_ PUCHAR ReadDataPort,
436 _In_ ULONG MaxLength,
437 _Out_ PUSHORT MaxLogDev,
438 _Out_ PULONG MaxTagsPerDevice)
439{
440 ULONG TagCount = 0;
441
442 PAGED_CODE();
443
444 *MaxLogDev = 0;
445 *MaxTagsPerDevice = 0;
446
447 while (TRUE)
448 {
449 UCHAR Tag;
450 USHORT TagLen;
451
452 ++TagCount;
453
454 if (MaxLength < 1)
455 {
456 DPRINT("Too small tag\n");
458 }
459
460 Tag = PeekByte(ReadDataPort);
461 if (Tag == 0)
462 {
463 DPRINT("Invalid tag\n");
465 }
466 *Buffer++ = Tag;
467 --MaxLength;
468
470 {
471 TagLen = ISAPNP_SMALL_TAG_LEN(Tag);
473 }
474 else
475 {
476 UCHAR Temp[2];
477
478 if (MaxLength < sizeof(Temp))
479 {
480 DPRINT("Too small tag\n");
482 }
483
484 Peek(ReadDataPort, &Temp, sizeof(Temp));
485 *Buffer++ = Temp[0];
486 *Buffer++ = Temp[1];
487 MaxLength -= sizeof(Temp);
488
489 TagLen = Temp[0] + (Temp[1] << 8);
491 }
492
493 if (Tag == 0xFF && TagLen == 0xFFFF)
494 {
495 DPRINT("Invalid tag\n");
497 }
498
499 if (TagLen > MaxLength)
500 {
501 DPRINT("Too large resource data structure\n");
503 }
504
505 Peek(ReadDataPort, Buffer, TagLen);
506 MaxLength -= TagLen;
507 Buffer += TagLen;
508
510 {
511 /* Attempt to guess the allocation size based on the tags available */
512 *MaxTagsPerDevice = max(*MaxTagsPerDevice, TagCount);
513 TagCount = 0;
514
515 (*MaxLogDev)++;
516 }
517 else if (Tag == ISAPNP_TAG_END)
518 {
519 *MaxTagsPerDevice = max(*MaxTagsPerDevice, TagCount);
520 break;
521 }
522 }
523
524 return STATUS_SUCCESS;
525}
526
527static
528CODE_SEG("PAGE")
529VOID
532{
534
535 PAGED_CODE();
536
537 if (LogDevice->FriendlyName)
538 ExFreePoolWithTag(LogDevice->FriendlyName, TAG_ISAPNP);
539
540 if (LogDevice->Resources)
541 ExFreePoolWithTag(LogDevice->Resources, TAG_ISAPNP);
542
543 Entry = LogDevice->CompatibleIdList.Flink;
544 while (Entry != &LogDevice->CompatibleIdList)
545 {
546 PISAPNP_COMPATIBLE_ID_ENTRY CompatibleId =
548
549 RemoveEntryList(&CompatibleId->IdLink);
550
551 Entry = Entry->Flink;
552
553 ExFreePoolWithTag(CompatibleId, TAG_ISAPNP);
554 }
555
556 ExFreePoolWithTag(LogDevice, TAG_ISAPNP);
557}
558
559static
560CODE_SEG("PAGE")
563 _In_ PUCHAR ResourceData,
564 _In_ USHORT LogDevToParse,
566{
567 USHORT LogDev;
569 PISAPNP_RESOURCE Resource = LogDevice->Resources;
570 PUCHAR IdStrPos = NULL;
571 USHORT IdStrLen = 0;
572
573 PAGED_CODE();
574
575 DPRINT("%s for CSN %u, LDN %u\n", __FUNCTION__, LogDevice->CSN, LogDevice->LDN);
576
577 LogDev = LogDevToParse + 1;
578
579 while (TRUE)
580 {
581 UCHAR Tag;
582 USHORT TagLen;
583
584 Tag = *ResourceData++;
585
587 {
588 TagLen = ISAPNP_SMALL_TAG_LEN(Tag);
590 }
591 else
592 {
593 TagLen = *ResourceData++;
594 TagLen += *ResourceData++ << 8;
595
597 }
598
599 switch (Tag)
600 {
602 {
603 ISAPNP_LOGDEVID Temp;
604
605 --LogDev;
606
607 if (LogDev != 0 ||
608 (TagLen > sizeof(ISAPNP_LOGDEVID) ||
609 TagLen < (sizeof(ISAPNP_LOGDEVID) - 1)))
610 {
611 goto SkipTag;
612 }
613
614 RtlCopyMemory(&Temp, ResourceData, TagLen);
615 ResourceData += TagLen;
616
617 DPRINT("Found tag 0x%X (len %u)\n"
618 " VendorId 0x%04X\n"
619 " ProdId 0x%04X\n",
620 Tag, TagLen,
621 Temp.VendorId,
622 Temp.ProdId);
623
624 IsaPnpExtractAscii(LogDevice->LogVendorId, Temp.VendorId);
625 LogDevice->LogProdId = RtlUshortByteSwap(Temp.ProdId);
626
627 break;
628 }
629
631 {
632 ISAPNP_COMPATID Temp;
633 PISAPNP_COMPATIBLE_ID_ENTRY CompatibleId;
634
635 if (LogDev != 0 || TagLen != sizeof(ISAPNP_COMPATID))
636 goto SkipTag;
637
638 CompatibleId = ExAllocatePoolWithTag(PagedPool,
640 TAG_ISAPNP);
641 if (!CompatibleId)
643
644 RtlCopyMemory(&Temp, ResourceData, TagLen);
645 ResourceData += TagLen;
646
647 DPRINT("Found tag 0x%X (len %u)\n"
648 " VendorId 0x%04X\n"
649 " ProdId 0x%04X\n",
650 Tag, TagLen,
651 Temp.VendorId,
652 Temp.ProdId);
653
654 IsaPnpExtractAscii(CompatibleId->VendorId, Temp.VendorId);
655 CompatibleId->ProdId = RtlUshortByteSwap(Temp.ProdId);
656
657 InsertTailList(&LogDevice->CompatibleIdList, &CompatibleId->IdLink);
658
659 break;
660 }
661
662 case ISAPNP_TAG_IRQ:
663 {
665
666 if (LogDev != 0)
667 goto SkipTag;
668
669 if (TagLen > sizeof(ISAPNP_IRQ_DESCRIPTION) ||
670 TagLen < (sizeof(ISAPNP_IRQ_DESCRIPTION) - 1))
671 {
672 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_IRQ);
673 return STATUS_UNSUCCESSFUL;
674 }
675
677 Description = &Resource->IrqDescription;
678 ++Resource;
679
680 RtlCopyMemory(Description, ResourceData, TagLen);
681 ResourceData += TagLen;
682
683 if (TagLen == (sizeof(ISAPNP_IRQ_DESCRIPTION) - 1))
684 Description->Information = 0x01;
685
686 DPRINT("Found tag 0x%X (len %u)\n"
687 " Mask 0x%X\n"
688 " Information 0x%X\n",
689 Tag, TagLen,
690 Description->Mask,
691 Description->Information);
692
693 break;
694 }
695
696 case ISAPNP_TAG_DMA:
697 {
699
700 if (LogDev != 0)
701 goto SkipTag;
702
703 if (TagLen != sizeof(ISAPNP_DMA_DESCRIPTION))
704 {
705 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_DMA);
706 return STATUS_UNSUCCESSFUL;
707 }
708
710 Description = &Resource->DmaDescription;
711 ++Resource;
712
713 RtlCopyMemory(Description, ResourceData, TagLen);
714 ResourceData += TagLen;
715
716 DPRINT("Found tag 0x%X (len %u)\n"
717 " Mask 0x%X\n"
718 " Information 0x%X\n",
719 Tag, TagLen,
720 Description->Mask,
721 Description->Information);
722
723 break;
724 }
725
727 {
728 if (LogDev != 0)
729 goto SkipTag;
730
731 if (TagLen > 1)
732 {
733 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_STARTDEP);
734 return STATUS_UNSUCCESSFUL;
735 }
736
737 if (DfState == dfNotStarted)
738 {
739 DfState = dfStarted;
740 }
741 else if (DfState != dfStarted)
742 {
743 goto SkipTag;
744 }
745
747 ++Resource;
748
749 if (TagLen != 1)
750 {
751 Resource->Priority = 1;
752 }
753 else
754 {
755 RtlCopyMemory(&Resource->Priority, ResourceData, TagLen);
756 ResourceData += TagLen;
757 }
758
759 DPRINT("*** Start dependent set, priority %u ***\n",
760 Resource->Priority);
761
762 break;
763 }
764
766 {
767 if (LogDev != 0 || DfState != dfStarted)
768 goto SkipTag;
769
771 ++Resource;
772
773 DfState = dfDone;
774
775 ResourceData += TagLen;
776
777 DPRINT("*** End of dependent set ***\n");
778
779 break;
780 }
781
783 {
785
786 if (LogDev != 0)
787 goto SkipTag;
788
789 if (TagLen != sizeof(ISAPNP_IO_DESCRIPTION))
790 {
791 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_IOPORT);
792 return STATUS_UNSUCCESSFUL;
793 }
794
796 Description = &Resource->IoDescription;
797 ++Resource;
798
799 RtlCopyMemory(Description, ResourceData, TagLen);
800 ResourceData += TagLen;
801
802 DPRINT("Found tag 0x%X (len %u)\n"
803 " Information 0x%X\n"
804 " Minimum 0x%X\n"
805 " Maximum 0x%X\n"
806 " Alignment 0x%X\n"
807 " Length 0x%X\n",
808 Tag, TagLen,
809 Description->Information,
810 Description->Minimum,
811 Description->Maximum,
812 Description->Alignment,
813 Description->Length);
814
815 break;
816 }
817
819 {
822
823 if (LogDev != 0)
824 goto SkipTag;
825
826 if (TagLen != sizeof(ISAPNP_FIXED_IO_DESCRIPTION))
827 {
828 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_FIXEDIO);
829 return STATUS_UNSUCCESSFUL;
830 }
831
833 Description = &Resource->IoDescription;
834 ++Resource;
835
836 RtlCopyMemory(&Temp, ResourceData, TagLen);
837 ResourceData += TagLen;
838
839 /* Save the address bits [0:9] */
840 Temp.IoBase &= ((1 << 10) - 1);
841
842 Description->Information = 0;
843 Description->Minimum =
844 Description->Maximum = Temp.IoBase;
845 Description->Alignment = 1;
846 Description->Length = Temp.Length;
847
848 DPRINT("Found tag 0x%X (len %u)\n"
849 " IoBase 0x%X\n"
850 " Length 0x%X\n",
851 Tag, TagLen,
852 Temp.IoBase,
853 Temp.Length);
854
855 break;
856 }
857
858 case ISAPNP_TAG_END:
859 {
860 if (IdStrPos)
861 {
862 PSTR End;
863
864 LogDevice->FriendlyName = ExAllocatePoolWithTag(PagedPool,
865 IdStrLen + sizeof(ANSI_NULL),
866 TAG_ISAPNP);
867 if (!LogDevice->FriendlyName)
869
870 RtlCopyMemory(LogDevice->FriendlyName, IdStrPos, IdStrLen);
871
872 End = LogDevice->FriendlyName + IdStrLen - 1;
873 while (End > LogDevice->FriendlyName && *End == ' ')
874 {
875 --End;
876 }
877 *++End = ANSI_NULL;
878 }
879
881
882 return STATUS_SUCCESS;
883 }
884
886 {
888
889 if (LogDev != 0)
890 goto SkipTag;
891
892 if (TagLen != sizeof(ISAPNP_MEMRANGE_DESCRIPTION))
893 {
894 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_MEMRANGE);
895 return STATUS_UNSUCCESSFUL;
896 }
897
898 LogDevice->Flags |= ISAPNP_HAS_MEM24_DECODER;
899 ASSERT(!(LogDevice->Flags & ISAPNP_HAS_MEM32_DECODER));
900
902 Description = &Resource->MemRangeDescription;
903 ++Resource;
904
905 RtlCopyMemory(Description, ResourceData, TagLen);
906 ResourceData += TagLen;
907
908 DPRINT("Found tag 0x%X (len %u)\n"
909 " Information 0x%X\n"
910 " Minimum 0x%X\n"
911 " Maximum 0x%X\n"
912 " Alignment 0x%X\n"
913 " Length 0x%X\n",
914 Tag, TagLen,
915 Description->Information,
916 Description->Minimum,
917 Description->Maximum,
918 Description->Alignment,
919 Description->Length);
920
921 break;
922 }
923
925 {
926 /* If logical device identifier is not supplied, use card identifier */
927 if (LogDev == LogDevToParse + 1 || LogDev == 0)
928 {
929 IdStrPos = ResourceData;
930 IdStrLen = TagLen;
931
932 ResourceData += TagLen;
933
934 DPRINT("Found tag 0x%X (len %u)\n"
935 " '%.*s'\n",
936 Tag, TagLen,
937 IdStrLen,
938 IdStrPos);
939 }
940 else
941 {
942 goto SkipTag;
943 }
944
945 break;
946 }
947
949 {
951
952 if (LogDev != 0)
953 goto SkipTag;
954
955 if (TagLen != sizeof(ISAPNP_MEMRANGE32_DESCRIPTION))
956 {
957 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_MEM32RANGE);
958 return STATUS_UNSUCCESSFUL;
959 }
960
961 LogDevice->Flags |= ISAPNP_HAS_MEM32_DECODER;
962 ASSERT(!(LogDevice->Flags & ISAPNP_HAS_MEM24_DECODER));
963
965 Description = &Resource->MemRange32Description;
966 ++Resource;
967
968 RtlCopyMemory(Description, ResourceData, TagLen);
969 ResourceData += TagLen;
970
971 DPRINT("Found tag 0x%X (len %u)\n"
972 " Information 0x%X\n"
973 " Minimum 0x%08lX\n"
974 " Maximum 0x%08lX\n"
975 " Alignment 0x%08lX\n"
976 " Length 0x%08lX\n",
977 Tag, TagLen,
978 Description->Information,
979 Description->Minimum,
980 Description->Maximum,
981 Description->Alignment,
982 Description->Length);
983
984 break;
985 }
986
988 {
991
992 if (LogDev != 0)
993 goto SkipTag;
994
995 if (TagLen != sizeof(ISAPNP_FIXEDMEMRANGE_DESCRIPTION))
996 {
997 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_FIXEDMEM32RANGE);
998 return STATUS_UNSUCCESSFUL;
999 }
1000
1001 LogDevice->Flags |= ISAPNP_HAS_MEM32_DECODER;
1002 ASSERT(!(LogDevice->Flags & ISAPNP_HAS_MEM24_DECODER));
1003
1005 Description = &Resource->MemRange32Description;
1006 ++Resource;
1007
1008 RtlCopyMemory(&Temp, ResourceData, TagLen);
1009 ResourceData += TagLen;
1010
1011 Description->Information = Temp.Information;
1012 Description->Minimum =
1013 Description->Maximum = Temp.MemoryBase;
1014 Description->Alignment = 1;
1015 Description->Length = Temp.Length;
1016
1017 DPRINT("Found tag 0x%X (len %u)\n"
1018 " Information 0x%X\n"
1019 " MemoryBase 0x%08lX\n"
1020 " Length 0x%08lX\n",
1021 Tag, TagLen,
1022 Temp.Information,
1023 Temp.MemoryBase,
1024 Temp.Length);
1025
1026 break;
1027 }
1028
1029SkipTag:
1030 default:
1031 {
1032 if (LogDev == 0)
1033 DPRINT("Found unknown tag 0x%X (len %u)\n", Tag, TagLen);
1034
1035 /* We don't want to read informations on this
1036 * logical device, or we don't know the tag. */
1037 ResourceData += TagLen;
1038 break;
1039 }
1040 }
1041 }
1042}
1043
1044static
1045CODE_SEG("PAGE")
1046BOOLEAN
1048 _In_ PUCHAR ReadDataPort,
1050{
1051 UCHAR i;
1052
1053 PAGED_CODE();
1054
1055 DPRINT("%s for CSN %u, LDN %u\n", __FUNCTION__, LogDevice->CSN, LogDevice->LDN);
1056
1057 WriteLogicalDeviceNumber(LogDevice->LDN);
1058
1059 /* If the device is not activated by BIOS then the device has no boot resources */
1060 if (!(ReadByte(ReadDataPort, ISAPNP_ACTIVATE) & 1))
1061 {
1062 LogDevice->Flags &= ~ISAPNP_HAS_RESOURCES;
1063 return FALSE;
1064 }
1065
1066 for (i = 0; i < RTL_NUMBER_OF(LogDevice->Io); i++)
1067 {
1068 LogDevice->Io[i].CurrentBase = ReadIoBase(ReadDataPort, i);
1069
1070 /* Skip empty descriptors */
1071 if (!LogDevice->Io[i].CurrentBase)
1072 break;
1073 }
1074 for (i = 0; i < RTL_NUMBER_OF(LogDevice->Irq); i++)
1075 {
1076 LogDevice->Irq[i].CurrentNo = ReadIrqNo(ReadDataPort, i);
1077
1078 if (!LogDevice->Irq[i].CurrentNo)
1079 break;
1080
1081 LogDevice->Irq[i].CurrentType = ReadIrqType(ReadDataPort, i);
1082 }
1083 for (i = 0; i < RTL_NUMBER_OF(LogDevice->Dma); i++)
1084 {
1085 LogDevice->Dma[i].CurrentChannel = ReadDmaChannel(ReadDataPort, i);
1086
1087 if (LogDevice->Dma[i].CurrentChannel == DMACHANNEL_NONE)
1088 break;
1089 }
1090 for (i = 0; i < RTL_NUMBER_OF(LogDevice->MemRange); i++)
1091 {
1092 LogDevice->MemRange[i].CurrentBase = ReadMemoryBase(ReadDataPort, i) << 8;
1093
1094 if (!LogDevice->MemRange[i].CurrentBase)
1095 break;
1096
1097 LogDevice->MemRange[i].CurrentLength = ReadMemoryLimit(ReadDataPort, i) << 8;
1098
1099 if (ReadMemoryControl(ReadDataPort, i) & MEMORY_UPPER_LIMIT)
1100 {
1101 LogDevice->MemRange[i].CurrentLength -= LogDevice->MemRange[i].CurrentBase;
1102 }
1103 else
1104 {
1105 LogDevice->MemRange[i].CurrentLength =
1106 RANGE_LENGTH_TO_LENGTH(LogDevice->MemRange[i].CurrentLength);
1107 }
1108 }
1109 for (i = 0; i < RTL_NUMBER_OF(LogDevice->MemRange32); i++)
1110 {
1111 LogDevice->MemRange32[i].CurrentBase = ReadMemoryBase32(ReadDataPort, i);
1112
1113 if (!LogDevice->MemRange32[i].CurrentBase)
1114 break;
1115
1116 LogDevice->MemRange32[i].CurrentLength = ReadMemoryLimit32(ReadDataPort, i);
1117
1118 if (ReadMemoryControl32(ReadDataPort, i) & MEMORY_UPPER_LIMIT)
1119 {
1120 LogDevice->MemRange32[i].CurrentLength -= LogDevice->MemRange32[i].CurrentBase;
1121 }
1122 else
1123 {
1124 LogDevice->MemRange32[i].CurrentLength =
1125 RANGE_LENGTH_TO_LENGTH(LogDevice->MemRange32[i].CurrentLength);
1126 }
1127 }
1128
1129 LogDevice->Flags |= ISAPNP_HAS_RESOURCES;
1130 return TRUE;
1131}
1132
1133static
1134CODE_SEG("PAGE")
1135VOID
1139{
1140 PAGED_CODE();
1141
1142 ASSERT(Descriptor->u.Port.Start.QuadPart <= 0xFFFF);
1143
1144 WriteWord(ISAPNP_IOBASE(Index), Descriptor->u.Port.Start.LowPart);
1145}
1146
1147static
1148CODE_SEG("PAGE")
1149VOID
1153{
1154 UCHAR TypeSelect;
1155
1156 PAGED_CODE();
1157
1158 ASSERT(Descriptor->u.Interrupt.Level <= 15);
1159
1161 TypeSelect = IRQTYPE_HIGH_EDGE;
1162 else
1163 TypeSelect = IRQTYPE_LOW_LEVEL;
1164
1165 WriteByte(ISAPNP_IRQNO(Index), Descriptor->u.Interrupt.Level);
1166 WriteByte(ISAPNP_IRQTYPE(Index), TypeSelect);
1167}
1168
1169static
1170CODE_SEG("PAGE")
1171VOID
1175{
1176 PAGED_CODE();
1177
1178 ASSERT(Descriptor->u.Dma.Channel <= 7);
1179
1180 WriteByte(ISAPNP_DMACHANNEL(Index), Descriptor->u.Dma.Channel);
1181}
1182
1183static
1184CODE_SEG("PAGE")
1187 _In_ PUCHAR ReadDataPort,
1189 _In_ BOOLEAN IsMemory32,
1192{
1193 UCHAR MemoryControl;
1194 ULONG LengthLimit;
1195
1196 PAGED_CODE();
1197
1198 if (!IsMemory32)
1199 {
1200 /* The 24-bit memory address decoder always considers bits 0:7 to be zeros */
1201 if (Descriptor->u.Memory.Start.LowPart & 0xFF)
1203
1205 MemoryControl = MEMORY_USE_16_BIT_DECODER;
1206 else
1207 MemoryControl = MEMORY_USE_8_BIT_DECODER;
1208
1209 if (ReadMemoryControl(ReadDataPort, Index) & MEMORY_UPPER_LIMIT)
1210 {
1211 MemoryControl |= MEMORY_UPPER_LIMIT;
1212 LengthLimit = Descriptor->u.Memory.Start.LowPart + Descriptor->u.Memory.Length;
1213 }
1214 else
1215 {
1216 LengthLimit = LENGTH_TO_RANGE_LENGTH(Descriptor->u.Memory.Length);
1217 }
1218 LengthLimit >>= 8;
1219
1220 WriteWord(ISAPNP_MEMBASE(Index), Descriptor->u.Memory.Start.LowPart >> 8);
1221 WriteByte(ISAPNP_MEMCONTROL(Index), MemoryControl);
1222 WriteWord(ISAPNP_MEMLIMIT(Index), LengthLimit);
1223 }
1224 else
1225 {
1227 MemoryControl = MEMORY_USE_32_BIT_DECODER;
1229 MemoryControl = MEMORY_USE_16_BIT_DECODER;
1230 else
1231 MemoryControl = MEMORY_USE_8_BIT_DECODER;
1232
1233 if (ReadMemoryControl32(ReadDataPort, Index) & MEMORY_UPPER_LIMIT)
1234 {
1235 MemoryControl |= MEMORY_UPPER_LIMIT;
1236 LengthLimit = Descriptor->u.Memory.Start.LowPart + Descriptor->u.Memory.Length;
1237 }
1238 else
1239 {
1240 LengthLimit = LENGTH_TO_RANGE_LENGTH(Descriptor->u.Memory.Length);
1241 }
1242
1243 WriteDoubleWord(ISAPNP_MEMBASE32(Index), Descriptor->u.Memory.Start.LowPart);
1244 WriteByte(ISAPNP_MEMCONTROL32(Index), MemoryControl);
1246 }
1247
1248 return STATUS_SUCCESS;
1249}
1250
1251CODE_SEG("PAGE")
1252UCHAR
1254 _In_ PUCHAR ReadDataPort)
1255{
1256 ULONG NumberOfRead = 0;
1257 UCHAR Csn = 0;
1258
1259 PAGED_CODE();
1260
1261 DPRINT("Setting read data port: 0x%p\n", ReadDataPort);
1262
1263 SendKey();
1264
1268
1269 SendKey();
1270
1271 Wake(0x00);
1273
1274 SetReadDataPort(ReadDataPort);
1275
1276 Wake(0x00);
1277
1278 while (TRUE)
1279 {
1281 UCHAR i, j;
1282 BOOLEAN Seen55aa = FALSE;
1283
1286
1288
1289 for (i = 0; i < sizeof(Identifier); i++)
1290 {
1291 UCHAR Byte = 0;
1292
1293 for (j = 0; j < RTL_BITS_OF(Byte); j++)
1294 {
1295 USHORT Data;
1296
1297 Data = ReadData(ReadDataPort) << 8;
1299 Data |= ReadData(ReadDataPort);
1301
1302 Byte >>= 1;
1303
1304 if (Data == 0x55AA)
1305 {
1306 Byte |= 0x80;
1307 Seen55aa = TRUE;
1308 }
1309 }
1310
1311 ((PUCHAR)&Identifier)[i] = Byte;
1312 }
1313
1314 ++NumberOfRead;
1315
1316 if (Identifier.Checksum != 0x00 &&
1317 Identifier.Checksum != IsaPnpChecksum(&Identifier))
1318 {
1319 DPRINT("Bad checksum\n");
1320 break;
1321 }
1322
1323 if (!Seen55aa)
1324 {
1325 DPRINT("Saw no sign of life\n");
1326 break;
1327 }
1328
1329 Csn++;
1330
1331 WriteCsn(Csn);
1333
1334 Wake(0x00);
1335 }
1336
1337 Wake(0x00);
1338
1339 if (NumberOfRead == 1)
1340 {
1341 DPRINT("Trying next read data port\n");
1342 return 0;
1343 }
1344 else
1345 {
1346 DPRINT("Found %u cards at read port 0x%p\n", Csn, ReadDataPort);
1347 return Csn;
1348 }
1349}
1350
1351_Requires_lock_held_(FdoExt->DeviceSyncEvent)
1352CODE_SEG("PAGE")
1354IsaHwFillDeviceList(
1356{
1357 PISAPNP_LOGICAL_DEVICE LogDevice;
1358 UCHAR Csn;
1360 PUCHAR ResourceData;
1361
1362 PAGED_CODE();
1363 ASSERT(FdoExt->ReadDataPort);
1364
1365 DPRINT("%s for read port 0x%p\n", __FUNCTION__, FdoExt->ReadDataPort);
1366
1368 if (!ResourceData)
1369 {
1370 DPRINT1("Failed to allocate memory for cache data\n");
1372 }
1373
1374 for (Entry = FdoExt->DeviceListHead.Flink;
1375 Entry != &FdoExt->DeviceListHead;
1376 Entry = Entry->Flink)
1377 {
1378 LogDevice = CONTAINING_RECORD(Entry, ISAPNP_LOGICAL_DEVICE, DeviceLink);
1379
1380 LogDevice->Flags &= ~ISAPNP_PRESENT;
1381 }
1382
1383 for (Csn = 1; Csn <= FdoExt->Cards; Csn++)
1384 {
1386 UCHAR TempId[3], LogDev;
1388 ULONG MaxTagsPerDevice;
1389 USHORT MaxLogDev;
1390
1391 Wake(Csn);
1392
1393 Peek(FdoExt->ReadDataPort, &Identifier, sizeof(Identifier));
1394
1395 IsaPnpExtractAscii(TempId, Identifier.VendorId);
1396 Identifier.ProdId = RtlUshortByteSwap(Identifier.ProdId);
1397
1398 Status = ReadTags(FdoExt->ReadDataPort,
1399 ResourceData,
1401 &MaxLogDev,
1402 &MaxTagsPerDevice);
1403 if (!NT_SUCCESS(Status))
1404 {
1405 DPRINT1("Failed to read tags with status 0x%08lx, CSN %u\n", Status, Csn);
1406 continue;
1407 }
1408
1409 DPRINT("Detected ISA PnP device - VID: '%.3s' PID: 0x%04x SN: 0x%08lX\n",
1410 TempId, Identifier.ProdId, Identifier.Serial);
1411
1412 for (LogDev = 0; LogDev < MaxLogDev; LogDev++)
1413 {
1414 BOOLEAN IsAlreadyEnumerated = FALSE;
1415
1416#ifndef UNIT_TEST
1417 for (Entry = FdoExt->DeviceListHead.Flink;
1418 Entry != &FdoExt->DeviceListHead;
1419 Entry = Entry->Flink)
1420 {
1421 LogDevice = CONTAINING_RECORD(Entry, ISAPNP_LOGICAL_DEVICE, DeviceLink);
1422
1423 /* This logical device has already been enumerated */
1424 if ((LogDevice->SerialNumber == Identifier.Serial) &&
1425 (RtlCompareMemory(LogDevice->VendorId, TempId, 3) == 3) &&
1426 (LogDevice->ProdId == Identifier.ProdId) &&
1427 (LogDevice->LDN == LogDev))
1428 {
1429 LogDevice->Flags |= ISAPNP_PRESENT;
1430
1431 /* Assign a new CSN */
1432 LogDevice->CSN = Csn;
1433
1434 if (LogDevice->Pdo)
1435 {
1437
1438 if (PdoExt->Common.State == dsStarted)
1439 ActivateDevice(FdoExt->ReadDataPort, LogDev);
1440 }
1441
1442 DPRINT("Skip CSN %u, LDN %u\n", LogDevice->CSN, LogDevice->LDN);
1443 IsAlreadyEnumerated = TRUE;
1444 break;
1445 }
1446 }
1447#endif /* UNIT_TEST */
1448
1449 if (IsAlreadyEnumerated)
1450 continue;
1451
1453 if (!LogDevice)
1454 {
1455 DPRINT1("Failed to allocate logical device!\n");
1456 goto Deactivate;
1457 }
1458
1460
1461 LogDevice->CSN = Csn;
1462 LogDevice->LDN = LogDev;
1463
1465 MaxTagsPerDevice * sizeof(ISAPNP_RESOURCE),
1466 TAG_ISAPNP);
1467 if (!LogDevice->Resources)
1468 {
1469 DPRINT1("Failed to allocate the resources array\n");
1470 FreeLogicalDevice(LogDevice);
1471 goto Deactivate;
1472 }
1473
1474 Status = ParseTags(ResourceData, LogDev, LogDevice);
1475 if (!NT_SUCCESS(Status))
1476 {
1477 DPRINT1("Failed to parse tags with status 0x%08lx, CSN %u, LDN %u\n",
1478 Status, LogDevice->CSN, LogDevice->LDN);
1479 FreeLogicalDevice(LogDevice);
1480 goto Deactivate;
1481 }
1482
1483 if (!ReadCurrentResources(FdoExt->ReadDataPort, LogDevice))
1484 DPRINT("Unable to read boot resources\n");
1485
1486 IsaPnpExtractAscii(LogDevice->VendorId, Identifier.VendorId);
1487 LogDevice->ProdId = Identifier.ProdId;
1488 LogDevice->SerialNumber = Identifier.Serial;
1489
1490 if (MaxLogDev > 1)
1491 LogDevice->Flags |= ISAPNP_HAS_MULTIPLE_LOGDEVS;
1492
1493 LogDevice->Flags |= ISAPNP_PRESENT;
1494
1495 InsertTailList(&FdoExt->DeviceListHead, &LogDevice->DeviceLink);
1496 FdoExt->DeviceCount++;
1497
1498 /* Now we wait for the start device IRP */
1499Deactivate:
1500 DeactivateDevice(LogDev);
1501 }
1502 }
1503
1504 ExFreePoolWithTag(ResourceData, TAG_ISAPNP);
1505
1506 return STATUS_SUCCESS;
1507}
1508
1509CODE_SEG("PAGE")
1513 _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice,
1515{
1516 ULONG i;
1517 UCHAR NumberOfIo = 0,
1518 NumberOfIrq = 0,
1519 NumberOfDma = 0,
1520 NumberOfMemory = 0,
1521 NumberOfMemory32 = 0;
1522
1523 PAGED_CODE();
1524
1525 if (!Resources)
1527
1528 WriteLogicalDeviceNumber(LogicalDevice->LDN);
1529
1530 for (i = 0; i < Resources->List[0].PartialResourceList.Count; i++)
1531 {
1533 &Resources->List[0].PartialResourceList.PartialDescriptors[i];
1534
1535 switch (Descriptor->Type)
1536 {
1537 case CmResourceTypePort:
1538 {
1539 if (NumberOfIo >= RTL_NUMBER_OF(LogicalDevice->Io))
1541
1542 IsaProgramIoDecoder(Descriptor, NumberOfIo++);
1543 break;
1544 }
1545
1547 {
1548 if (NumberOfIrq >= RTL_NUMBER_OF(LogicalDevice->Irq))
1550
1551 IsaProgramIrqSelect(Descriptor, NumberOfIrq++);
1552 break;
1553 }
1554
1555 case CmResourceTypeDma:
1556 {
1557 if (NumberOfDma >= RTL_NUMBER_OF(LogicalDevice->Dma))
1559
1560 IsaProgramDmaSelect(Descriptor, NumberOfDma++);
1561 break;
1562 }
1563
1565 {
1566 BOOLEAN IsMemory32;
1569
1570 if ((NumberOfMemory + NumberOfMemory32) >= RTL_NUMBER_OF(LogicalDevice->MemRange))
1572
1573 /*
1574 * The PNP ROM provides an information byte for each memory descriptor
1575 * which is then used to program the memory control register.
1576 */
1577 if (!FindMemoryDescriptor(LogicalDevice,
1578 Descriptor->u.Memory.Start.LowPart,
1579 Descriptor->u.Memory.Start.LowPart +
1580 Descriptor->u.Memory.Length - 1,
1581 &Information))
1582 {
1584 }
1585
1586 /* We can have a 24- or 32-bit memory decoder, but not both */
1587 IsMemory32 = !!(LogicalDevice->Flags & ISAPNP_HAS_MEM32_DECODER);
1588
1589 if (IsMemory32)
1590 Index = NumberOfMemory32++;
1591 else
1592 Index = NumberOfMemory++;
1593
1594 Status = IsaProgramMemoryDecoder(FdoExt->ReadDataPort,
1595 Descriptor,
1596 IsMemory32,
1598 Index);
1599 if (!NT_SUCCESS(Status))
1600 return Status;
1601
1602 break;
1603 }
1604
1605 default:
1606 break;
1607 }
1608 }
1609
1610 /* Disable the unclaimed device resources */
1611 for (i = NumberOfIo; i < RTL_NUMBER_OF(LogicalDevice->Io); i++)
1612 {
1614 }
1615 for (i = NumberOfIrq; i < RTL_NUMBER_OF(LogicalDevice->Irq); i++)
1616 {
1619 }
1620 for (i = NumberOfDma; i < RTL_NUMBER_OF(LogicalDevice->Dma); i++)
1621 {
1623 }
1624 for (i = NumberOfMemory; i < RTL_NUMBER_OF(LogicalDevice->MemRange); i++)
1625 {
1629 }
1630 for (i = NumberOfMemory32; i < RTL_NUMBER_OF(LogicalDevice->MemRange32); i++)
1631 {
1635 }
1636
1638
1639 return STATUS_SUCCESS;
1640}
1641
1642CODE_SEG("PAGE")
1643VOID
1645 _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
1646{
1647 PAGED_CODE();
1648
1649 SendKey();
1650 Wake(LogicalDevice->CSN);
1651}
1652
1653CODE_SEG("PAGE")
1654VOID
1657 _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
1658{
1659 PAGED_CODE();
1660
1661 ActivateDevice(FdoExt->ReadDataPort, LogicalDevice->LDN);
1662}
1663
1664#ifndef UNIT_TEST
1665CODE_SEG("PAGE")
1666VOID
1668 _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
1669{
1670 PAGED_CODE();
1671
1672 DeactivateDevice(LogicalDevice->LDN);
1673}
1674#endif /* UNIT_TEST */
1675
1676CODE_SEG("PAGE")
1677VOID
1679{
1680 PAGED_CODE();
1681
1682 WaitForKey();
1683}
#define PAGED_CODE()
#define CODE_SEG(...)
unsigned char BOOLEAN
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
@ ReadData
Definition: amstream.idl:63
@ Identifier
Definition: asmpp.cpp:95
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
Definition: bufpool.h:45
#define _Requires_lock_held_(lock)
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static const WCHAR Description[]
Definition: oid.c:1266
unsigned char Byte
Definition: zlib.h:37
static VOID WriteDoubleWord(_In_ UCHAR Address, _In_ ULONG Value)
Definition: hardware.c:77
static ULONG ReadDoubleWord(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
Definition: hardware.c:112
static VOID SetReadDataPort(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:123
VOID IsaHwWakeDevice(_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
Definition: hardware.c:1644
static VOID SendKey(VOID)
Definition: hardware.c:332
static NTSTATUS ParseTags(_In_ PUCHAR ResourceData, _In_ USHORT LogDevToParse, _Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
Definition: hardware.c:562
static USHORT ReadMemoryLimit(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:278
static USHORT ReadIoBase(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:218
static UCHAR ReadIrqType(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:238
static USHORT ReadWord(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
Definition: hardware.c:101
static VOID Peek(_In_ PUCHAR ReadDataPort, _Out_writes_bytes_all_opt_(Length) PVOID Buffer, _In_ USHORT Length)
Definition: hardware.c:373
static VOID IsaProgramIrqSelect(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
Definition: hardware.c:1150
static VOID WriteCsn(_In_ UCHAR Csn)
Definition: hardware.c:175
static VOID ActivateDevice(_In_ PUCHAR ReadDataPort, _In_ UCHAR LogDev)
Definition: hardware.c:193
VOID IsaHwWaitForKey(VOID)
Definition: hardware.c:1678
static UCHAR ReadIrqNo(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:228
static VOID IsaProgramDmaSelect(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
Definition: hardware.c:1172
static VOID FreeLogicalDevice(_In_ __drv_freesMem(Mem) PISAPNP_LOGICAL_DEVICE LogDevice)
Definition: hardware.c:530
static VOID WriteByte(_In_ UCHAR Address, _In_ UCHAR Value)
Definition: hardware.c:53
static UCHAR ReadMemoryControl(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:268
VOID IsaHwDeactivateDevice(_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
Definition: hardware.c:1667
static UCHAR ReadByte(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
Definition: hardware.c:88
static VOID EnterIsolationState(VOID)
Definition: hardware.c:132
UCHAR IsaHwTryReadDataPort(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:1253
static ULONG ReadMemoryBase32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:288
static UCHAR ReadStatus(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:166
static VOID IsaProgramIoDecoder(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
Definition: hardware.c:1136
static UCHAR NextLFSR(_In_ UCHAR Lfsr, _In_ UCHAR InputBit)
Definition: hardware.c:318
static VOID DeactivateDevice(_In_ UCHAR LogDev)
Definition: hardware.c:208
static VOID WriteLogicalDeviceNumber(_In_ UCHAR LogDev)
Definition: hardware.c:184
static UCHAR ReadMemoryControl32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:298
static VOID WriteAddress(_In_ UCHAR Address)
Definition: hardware.c:26
static VOID Wake(_In_ UCHAR Csn)
Definition: hardware.c:148
static UCHAR ReadResourceData(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:157
static VOID WriteWord(_In_ UCHAR Address, _In_ USHORT Value)
Definition: hardware.c:66
static ULONG ReadMemoryLimit32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:308
static NTSTATUS IsaProgramMemoryDecoder(_In_ PUCHAR ReadDataPort, _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ BOOLEAN IsMemory32, _In_ UCHAR Information, _In_ UCHAR Index)
Definition: hardware.c:1186
static VOID IsaPnpExtractAscii(_Out_writes_all_(3) PUCHAR Buffer, _In_ USHORT CompressedData)
Definition: hardware.c:419
static USHORT ReadMemoryBase(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:258
static UCHAR ReadDmaChannel(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:248
static VOID WaitForKey(VOID)
Definition: hardware.c:140
static NTSTATUS ReadTags(_In_ PUCHAR ReadDataPort, _Out_writes_(ISAPNP_MAX_RESOURCEDATA) PUCHAR Buffer, _In_ ULONG MaxLength, _Out_ PUSHORT MaxLogDev, _Out_ PULONG MaxTagsPerDevice)
Definition: hardware.c:433
NTSTATUS IsaHwConfigureDevice(_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice, _In_ PCM_RESOURCE_LIST Resources)
Definition: hardware.c:1511
static UCHAR PeekByte(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:352
VOID IsaHwActivateDevice(_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
Definition: hardware.c:1655
static UCHAR IsaPnpChecksum(_In_ PISAPNP_IDENTIFIER Identifier)
Definition: hardware.c:394
static BOOLEAN ReadCurrentResources(_In_ PUCHAR ReadDataPort, _Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
Definition: hardware.c:1047
static VOID WriteData(_In_ UCHAR Data)
Definition: hardware.c:35
#define __FUNCTION__
Definition: types.h:116
#define __drv_freesMem(kind)
Definition: driverspecs.h:272
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define CmResourceTypeDma
Definition: hwresource.cpp:126
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
BOOLEAN FindMemoryDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG RangeStart, _In_ ULONG RangeEnd, _Out_opt_ PUCHAR Information)
Definition: isapnp.c:560
#define TAG_ISAPNP
Definition: isapnp.h:26
@ dsStarted
Definition: isapnp.h:31
#define ISAPNP_MEMBASE32(n)
Definition: isapnphw.h:50
#define ISAPNP_TAG_FIXEDIO
Definition: isapnphw.h:71
#define RANGE_LENGTH_TO_LENGTH(RangeLength)
Definition: isapnphw.h:84
#define ISAPNP_TAG_ANSISTR
Definition: isapnphw.h:79
#define ISAPNP_IORANGECHECK
Definition: isapnphw.h:34
#define ISAPNP_MEMCONTROL32(n)
Definition: isapnphw.h:51
#define ISAPNP_LFSR_SEED
Definition: isapnphw.h:58
#define ISAPNP_TAG_STARTDEP
Definition: isapnphw.h:68
#define IRQTYPE_LOW_LEVEL
Definition: isapnphw.h:46
#define ISAPNP_MEMLIMIT(n)
Definition: isapnphw.h:42
#define ISAPNP_LOGICALDEVICENUMBER
Definition: isapnphw.h:31
#define MEMORY_USE_32_BIT_DECODER
Definition: isapnphw.h:41
#define ISAPNP_MEMLIMIT32(n)
Definition: isapnphw.h:52
#define ISAPNP_SERIALISOLATION
Definition: isapnphw.h:25
#define ISAPNP_DMACHANNEL(n)
Definition: isapnphw.h:48
#define ISAPNP_TAG_MEMRANGE
Definition: isapnphw.h:76
#define ISAPNP_TAG_MEM32RANGE
Definition: isapnphw.h:81
#define ISAPNP_ACTIVATE
Definition: isapnphw.h:33
#define ISAPNP_ADDRESS
Definition: isapnphw.h:20
#define ISAPNP_TAG_DMA
Definition: isapnphw.h:67
#define MEMORY_USE_8_BIT_DECODER
Definition: isapnphw.h:39
#define ISAPNP_MEMBASE(n)
Definition: isapnphw.h:36
#define ISAPNP_RESOURCEDATA
Definition: isapnphw.h:28
#define ISAPNP_SMALL_TAG_NAME(t)
Definition: isapnphw.h:61
#define MEMORY_USE_16_BIT_DECODER
Definition: isapnphw.h:40
#define ISAPNP_READPORT
Definition: isapnphw.h:24
#define ISAPNP_TAG_IRQ
Definition: isapnphw.h:66
#define ISAPNP_TAG_COMPATDEVID
Definition: isapnphw.h:65
#define MEMORY_UPPER_LIMIT
Definition: isapnphw.h:38
#define ISAPNP_MEMCONTROL(n)
Definition: isapnphw.h:37
#define ISAPNP_SMALL_TAG_LEN(t)
Definition: isapnphw.h:62
#define ISAPNP_TAG_ENDDEP
Definition: isapnphw.h:69
#define ISAPNP_IRQTYPE(n)
Definition: isapnphw.h:45
#define IRQTYPE_HIGH_EDGE
Definition: isapnphw.h:47
#define ISAPNP_LARGE_TAG_NAME(t)
Definition: isapnphw.h:75
#define ISAPNP_IRQNO(n)
Definition: isapnphw.h:44
#define LENGTH_TO_RANGE_LENGTH(Length)
Definition: isapnphw.h:85
#define ISAPNP_WAKE
Definition: isapnphw.h:27
#define ISAPNP_STATUS
Definition: isapnphw.h:29
#define ISAPNP_CARDSELECTNUMBER
Definition: isapnphw.h:30
#define ISAPNP_IS_SMALL_TAG(t)
Definition: isapnphw.h:60
#define ISAPNP_TAG_LOGDEVID
Definition: isapnphw.h:64
#define DMACHANNEL_NONE
Definition: isapnphw.h:49
#define ISAPNP_WRITE_DATA
Definition: isapnphw.h:21
#define MEMRANGE_16_BIT_MEMORY_MASK
Definition: isapnphw.h:77
#define ISAPNP_TAG_END
Definition: isapnphw.h:72
#define ISAPNP_IOBASE(n)
Definition: isapnphw.h:43
#define ISAPNP_CONFIG_WAIT_FOR_KEY
Definition: isapnphw.h:55
#define ISAPNP_CONFIGCONTROL
Definition: isapnphw.h:26
#define ISAPNP_TAG_FIXEDMEM32RANGE
Definition: isapnphw.h:82
#define ISAPNP_CONFIG_RESET_CSN
Definition: isapnphw.h:56
#define MEMRANGE_32_BIT_MEMORY_ONLY
Definition: isapnphw.h:78
#define ISAPNP_TAG_IOPORT
Definition: isapnphw.h:70
#define ISAPNP_RESOURCE_TYPE_MEMRANGE
Definition: isapnpres.h:73
ISAPNP_DEPENDENT_FUNCTION_STATE
Definition: isapnpres.h:60
@ dfDone
Definition: isapnpres.h:63
@ dfStarted
Definition: isapnpres.h:62
@ dfNotStarted
Definition: isapnpres.h:61
#define ISAPNP_HAS_MULTIPLE_LOGDEVS
Definition: isapnpres.h:99
#define ISAPNP_HAS_MEM32_DECODER
Definition: isapnpres.h:108
#define ISAPNP_RESOURCE_TYPE_END
Definition: isapnpres.h:69
#define ISAPNP_RESOURCE_TYPE_IRQ
Definition: isapnpres.h:71
#define ISAPNP_HAS_MEM24_DECODER
Definition: isapnpres.h:105
#define ISAPNP_MAX_RESOURCEDATA
Maximum size of resource data structure supported by the driver.
Definition: isapnpres.h:12
#define ISAPNP_PRESENT
Definition: isapnpres.h:96
#define ISAPNP_RESOURCE_TYPE_IO
Definition: isapnpres.h:70
#define ISAPNP_RESOURCE_TYPE_START_DEPENDENT
Definition: isapnpres.h:75
#define ISAPNP_RESOURCE_TYPE_MEMRANGE32
Definition: isapnpres.h:74
#define ISAPNP_RESOURCE_TYPE_END_DEPENDENT
Definition: isapnpres.h:76
#define ISAPNP_RESOURCE_TYPE_DMA
Definition: isapnpres.h:72
#define ISAPNP_HAS_RESOURCES
Definition: isapnpres.h:102
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define KeStallExecutionProcessor(MicroSeconds)
Definition: precomp.h:27
#define _Inout_
Definition: ms_sal.h:378
#define _Out_writes_all_(size)
Definition: ms_sal.h:357
#define _Out_writes_(size)
Definition: ms_sal.h:348
#define _Out_
Definition: ms_sal.h:345
#define _Out_writes_bytes_all_opt_(size)
Definition: ms_sal.h:363
#define _In_
Definition: ms_sal.h:308
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
#define RTL_BITS_OF(sizeOfArg)
Definition: ntbasedef.h:668
#define ANSI_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:478
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
#define STATUS_RESOURCE_DATA_NOT_FOUND
Definition: ntstatus.h:373
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:477
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
PVOID DeviceExtension
Definition: env_spec_w32.h:418
Definition: isapnpres.h:53
UCHAR VendorId[3]
Definition: isapnpres.h:54
LIST_ENTRY IdLink
Definition: isapnpres.h:56
USHORT ProdId
Definition: isapnpres.h:55
USHORT VendorId
Definition: isapnphw.h:106
USHORT VendorId
Definition: isapnphw.h:99
LIST_ENTRY CompatibleIdList
Definition: isapnpres.h:129
PDEVICE_OBJECT Pdo
Definition: isapnpres.h:92
PISAPNP_RESOURCE Resources
Definition: isapnpres.h:127
LIST_ENTRY DeviceLink
Definition: isapnpres.h:91
Definition: typedefs.h:120
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:204
#define max(a, b)
Definition: svc.c:63
uint32_t * PULONG
Definition: typedefs.h:59
char * PSTR
Definition: typedefs.h:51
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint16_t * PUSHORT
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PUSBHUB_PORT_PDO_EXTENSION NTAPI PdoExt(IN PDEVICE_OBJECT DeviceObject)
Definition: usbhub.c:133
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
#define RtlUshortByteSwap(_x)
Definition: rtlfuncs.h:3197
unsigned char UCHAR
Definition: xmlstorage.h:181