2 * pnpdump - PnP BIOS information dumper
13 typedef struct _CM_PNP_BIOS_DEVICE_NODE
19 USHORT DeviceAttributes
;
20 } CM_PNP_BIOS_DEVICE_NODE
,*PCM_PNP_BIOS_DEVICE_NODE
;
22 typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK
24 UCHAR Signature
[4]; // $PnP (ascii)
29 ULONG EventFlagAddress
; // Physical address
30 USHORT RealModeEntryOffset
;
31 USHORT RealModeEntrySegment
;
32 USHORT ProtectedModeEntryOffset
;
33 ULONG ProtectedModeCodeBaseAddress
;
35 USHORT RealModeDataBaseAddress
;
36 ULONG ProtectedModeDataBaseAddress
;
37 } CM_PNP_BIOS_INSTALLATION_CHECK
, *PCM_PNP_BIOS_INSTALLATION_CHECK
;
41 typedef struct _PNP_ID_NAME_
45 } PNP_ID_NAME
, *PPNP_ID_NAME
;
48 static char Hex
[] = "0123456789ABCDEF";
50 static PNP_ID_NAME PnpName
[] =
52 /* Interrupt Controllers */
53 {"PNP0000", "AT Interrupt Controller"},
54 {"PNP0001", "EISA Interrupt Controller"},
55 {"PNP0002", "MCA Interrupt Controller"},
57 {"PNP0004", "Cyrix SLiC MP Interrupt Controller"},
60 {"PNP0100", "AT Timer"},
61 {"PNP0101", "EISA Timer"},
62 {"PNP0102", "MCA Timer"},
65 {"PNP0200", "AT DMA Controller"},
66 {"PNP0201", "EISA DMA Controller"},
67 {"PNP0202", "MCA DMA Controller"},
70 {"PNP0300", "IBM PC/XT Keyboard (83 keys)"},
71 {"PNP0301", "IBM PC/AT Keyboard (86 keys)"},
72 {"PNP0302", "IBM PC/XT Keyboard (84 keys)"},
73 {"PNP0303", "IBM Enhanced (101/102 keys)"},
74 {"PNP0304", "Olivetti Keyboard (83 keys)"},
75 {"PNP0305", "Olivetti Keyboard (102 keys)"},
76 {"PNP0306", "Olivetti Keyboard (86 keys)"},
77 {"PNP0307", "Microsoft Windows(R) Keyboard"},
78 {"PNP0308", "General Input Device Emulation Interface (GIDEI) legacy"},
79 {"PNP0309", "Olivetti Keyboard (A101/102 key)"},
80 {"PNP030A", "AT&T 302 keyboard"},
81 {"PNP030B", "Reserved by Microsoft"},
82 {"PNP0320", "Japanese 101-key keyboard"},
83 {"PNP0321", "Japanese AX keyboard"},
84 {"PNP0322", "Japanese 106-key keyboard A01"},
85 {"PNP0323", "Japanese 106-key keyboard 002/003"},
86 {"PNP0324", "Japanese 106-key keyboard 001"},
87 {"PNP0325", "Japanese Toshiba Desktop keyboard"},
88 {"PNP0326", "Japanese Toshiba Laptop keyboard"},
89 {"PNP0327", "Japanese Toshiba Notebook keyboard"},
90 {"PNP0340", "Korean 84-key keyboard"},
91 {"PNP0341", "Korean 86-key keyboard"},
92 {"PNP0342", "Korean Enhanced keyboard"},
93 {"PNP0343", "Korean Enhanced keyboard 101b"},
94 {"PNP0343", "Korean Enhanced keyboard 101c"},
95 {"PNP0344", "Korean Enhanced keyboard 103"},
98 {"PNP0400", "Standard LPT printer port"},
99 {"PNP0401", "ECP printer port"},
102 {"PNP0500", "Standard PC COM port"},
103 {"PNP0501", "16550A-compatible COM port"},
104 {"PNP0510", "Generic IRDA-compatible port"},
106 /* Harddisk Controllers */
107 {"PNP0600", "Generic ESDI/ATA/IDE harddisk controller"},
108 {"PNP0601", "Plus Hardcard II"},
109 {"PNP0602", "Plus Hardcard IIXL/EZ"},
110 {"PNP0603", "Generic IDE supporting Microsoft Device Bay Specification"},
112 /* Floppy Controllers */
113 {"PNP0700", "PC standard floppy disk controller"},
114 {"PNP0701", "Standard floppy controller supporting MS Device Bay Specification"},
116 /* obsolete devices */
117 {"PNP0800", "Microsoft Sound System compatible device"},
119 /* Display Adapters */
120 {"PNP0900", "VGA Compatible"},
121 {"PNP0901", "Video Seven VRAM/VRAM II/1024i"},
122 {"PNP0902", "8514/A Compatible"},
123 {"PNP0903", "Trident VGA"},
124 {"PNP0904", "Cirrus Logic Laptop VGA"},
125 {"PNP0905", "Cirrus Logic VGA"},
126 {"PNP0906", "Tseng ET4000"},
127 {"PNP0907", "Western Digital VGA"},
128 {"PNP0908", "Western Digital Laptop VGA"},
129 {"PNP0909", "S3 Inc. 911/924"},
130 {"PNP090A", "ATI Ultra Pro/Plus (Mach 32)"},
131 {"PNP090B", "ATI Ultra (Mach 8)"},
132 {"PNP090C", "XGA Compatible"},
133 {"PNP090D", "ATI VGA Wonder"},
134 {"PNP090E", "Weitek P9000 Graphics Adapter"},
135 {"PNP090F", "Oak Technology VGA"},
136 {"PNP0910", "Compaq QVision"},
137 {"PNP0911", "XGA/2"},
138 {"PNP0912", "Tseng Labs W32/W32i/W32p"},
139 {"PNP0913", "S3 Inc. 801/928/964"},
140 {"PNP0914", "Cirrus Logic 5429/5434 (memory mapped)"},
141 {"PNP0915", "Compaq Advanced VGA (AVGA)"},
142 {"PNP0916", "ATI Ultra Pro Turbo (Mach64)"},
143 {"PNP0917", "Reserved by Microsoft"},
144 {"PNP0918", "Matrox MGA"},
145 {"PNP0919", "Compaq QVision 2000"},
146 {"PNP091A", "Tseng W128"},
147 {"PNP0930", "Chips & Technologies Super VGA"},
148 {"PNP0931", "Chips & Technologies Accelerator"},
149 {"PNP0940", "NCR 77c22e Super VGA"},
150 {"PNP0941", "NCR 77c32blt"},
151 {"PNP09FF", "Plug and Play Monitors (VESA DDC)"},
153 /* Peripheral Buses */
154 {"PNP0A00", "ISA Bus"},
155 {"PNP0A01", "EISA Bus"},
156 {"PNP0A02", "MCA Bus"},
157 {"PNP0A03", "PCI Bus"},
158 {"PNP0A04", "VESA/VL Bus"},
159 {"PNP0A05", "Generic ACPI Bus"},
160 {"PNP0A06", "Generic ACPI Extended-IO Bus (EIO bus)"},
163 {"PNP0800", "AT-style speaker sound"},
164 {"PNP0B00", "AT Real-Time Clock"},
165 {"PNP0C00", "Plug and Play BIOS (only created by the root enumerator)"},
166 {"PNP0C01", "System Board"},
167 {"PNP0C02", "General Plug and Play motherboard registers."},
168 {"PNP0C03", "Plug and Play BIOS Event Notification Interrupt"},
169 {"PNP0C04", "Math Coprocessor"},
170 {"PNP0C05", "APM BIOS (Version independent)"},
171 {"PNP0C06", "Reserved for identification of early Plug and Play BIOS implementation"},
172 {"PNP0C07", "Reserved for identification of early Plug and Play BIOS implementation"},
173 {"PNP0C08", "ACPI system board hardware"},
174 {"PNP0C09", "ACPI Embedded Controller"},
175 {"PNP0C0A", "ACPI Control Method Battery"},
176 {"PNP0C0B", "ACPI Fan"},
177 {"PNP0C0C", "ACPI power button device"},
178 {"PNP0C0D", "ACPI lid device"},
179 {"PNP0C0E", "ACPI sleep button device"},
180 {"PNP0C0F", "PCI interrupt link device"},
181 {"PNP0C10", "ACPI system indicator device"},
182 {"PNP0C11", "ACPI thermal zone"},
183 {"PNP0C12", "Device Bay Controller"},
185 /* PCMCIA Controllers */
186 {"PNP0E00", "Intel 82365-Compatible PCMCIA Controller"},
187 {"PNP0E01", "Cirrus Logic CL-PD6720 PCMCIA Controller"},
188 {"PNP0E02", "VLSI VL82C146 PCMCIA Controller"},
189 {"PNP0E03", "Intel 82365-compatible CardBus controller"},
192 {"PNP0F00", "Microsoft Bus Mouse"},
193 {"PNP0F01", "Microsoft Serial Mouse"},
194 {"PNP0F02", "Microsoft InPort Mouse"},
195 {"PNP0F03", "Microsoft PS/2-style Mouse"},
196 {"PNP0F04", "Mouse Systems Mouse"},
197 {"PNP0F05", "Mouse Systems 3-Button Mouse (COM2)"},
198 {"PNP0F06", "Genius Mouse (COM1)"},
199 {"PNP0F07", "Genius Mouse (COM2)"},
200 {"PNP0F08", "Logitech Serial Mouse"},
201 {"PNP0F09", "Microsoft BallPoint Serial Mouse"},
202 {"PNP0F0A", "Microsoft Plug and Play Mouse"},
203 {"PNP0F0B", "Microsoft Plug and Play BallPoint Mouse"},
204 {"PNP0F0C", "Microsoft-compatible Serial Mouse"},
205 {"PNP0F0D", "Microsoft-compatible InPort-compatible Mouse"},
206 {"PNP0F0E", "Microsoft-compatible PS/2-style Mouse"},
207 {"PNP0F0F", "Microsoft-compatible Serial BallPoint-compatible Mouse"},
208 {"PNP0F10", "Texas Instruments QuickPort Mouse"},
209 {"PNP0F11", "Microsoft-compatible Bus Mouse"},
210 {"PNP0F12", "Logitech PS/2-style Mouse"},
211 {"PNP0F13", "PS/2 Port for PS/2-style Mice"},
212 {"PNP0F14", "Microsoft Kids Mouse"},
213 {"PNP0F15", "Logitech bus mouse"},
214 {"PNP0F16", "Logitech SWIFT device"},
215 {"PNP0F17", "Logitech-compatible serial mouse"},
216 {"PNP0F18", "Logitech-compatible bus mouse"},
217 {"PNP0F19", "Logitech-compatible PS/2-style Mouse"},
218 {"PNP0F1A", "Logitech-compatible SWIFT Device"},
219 {"PNP0F1B", "HP Omnibook Mouse"},
220 {"PNP0F1C", "Compaq LTE Trackball PS/2-style Mouse"},
221 {"PNP0F1D", "Compaq LTE Trackball Serial Mouse"},
222 {"PNP0F1E", "Microsoft Kids Trackball Mouse"},
223 {"PNP0F1F", "Reserved by Microsoft Input Device Group"},
224 {"PNP0F20", "Reserved by Microsoft Input Device Group"},
225 {"PNP0F21", "Reserved by Microsoft Input Device Group"},
226 {"PNP0F22", "Reserved by Microsoft Input Device Group"},
227 {"PNP0F23", "Reserved by Microsoft Input Device Group"},
228 {"PNP0FFF", "Reserved by Microsoft Systems"},
230 /* List Terminator */
235 /* FUNCTIONS ****************************************************************/
238 GetDeviceName(char *PnpId
)
243 while (IdName
->PnpId
!= NULL
)
245 if (!strcmp(IdName
->PnpId
, PnpId
))
246 return IdName
->DeviceName
;
251 return "Unknown Device";
256 GetPnpKey(PHKEY PnpKey
)
268 lError
= RegOpenKey(HKEY_LOCAL_MACHINE
,
269 "HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter",
271 if (lError
!= ERROR_SUCCESS
)
274 /* Enumerate buses */
275 for (dwBus
= 0; ; dwBus
++)
277 sprintf(szBuffer
, "%lu", dwBus
);
279 lError
= RegOpenKey(hAdapterKey
,
282 if (lError
!= ERROR_SUCCESS
)
284 RegCloseKey(hAdapterKey
);
289 lError
= RegQueryValueEx(hBusKey
,
295 if (lError
!= ERROR_SUCCESS
)
297 RegCloseKey(hBusKey
);
298 RegCloseKey(hAdapterKey
);
302 if (dwType
== REG_SZ
&& stricmp(szBuffer
, "pnp bios") == 0)
305 RegCloseKey(hAdapterKey
);
306 return ERROR_SUCCESS
;
309 RegCloseKey(hBusKey
);
317 PnpDecodeIrq(unsigned char *Ptr
)
324 IrqMask
|= (*Ptr
<< 8);
328 for (i
= 0; i
< 16; i
++)
330 if (IrqMask
& (1 << i
))
341 PnpDecodeDma(unsigned char *Ptr
)
343 unsigned char DmaChannel
;
344 unsigned char DmaStatus
;
353 for (i
= 0; i
< 8; i
++)
355 if (DmaChannel
& (1 << i
))
366 PnpDecodeIoPort(unsigned char *Ptr
)
377 MinBase
+= (*Ptr
<< 8);
381 MaxBase
+= (*Ptr
<< 8);
387 printf(" I/O Port descriptor\n");
388 printf(" MinBase 0x%x MaxBase 0x%x Align %u Length %u\n",
389 MinBase
, MaxBase
, Align
, Length
);
394 PnpDecodeFixedIoPort(unsigned char *Ptr
)
401 IoPort
+= (*Ptr
<< 8);
405 printf(" Fixed I/O Port descriptor\n");
406 printf(" PortBase 0x%hx Length 0x%x\n",
412 printf(" Fixed location I/O Port descriptor: 0x%x\n",
417 printf(" Fixed location I/O Port descriptor: 0x%x - 0x%x\n",
419 IoPort
+ Length
- 1);
426 PnpDecodeMemory16(unsigned char *Ptr
)
439 MinBase
+= (*Ptr
<< 8);
444 MaxBase
+= (*Ptr
<< 8);
449 Align
+= (*Ptr
<< 8);
454 Length
+= (*Ptr
<< 8);
456 printf(" 16-Bit memory range descriptor\n");
457 printf(" MinBase 0x%hx MaxBase 0x%hx Align 0x%hx Length 0x%hx Flags 0x%02x\n",
458 MinBase
, MaxBase
, Align
,Length
, Info
);
463 PnpDecodeMemory32(unsigned char *Ptr
)
476 MinBase
+= (*Ptr
<< 8);
478 MinBase
+= (*Ptr
<< 16);
480 MinBase
+= (*Ptr
<< 24);
485 MaxBase
+= (*Ptr
<< 8);
487 MaxBase
+= (*Ptr
<< 16);
489 MaxBase
+= (*Ptr
<< 24);
494 Align
+= (*Ptr
<< 8);
496 Align
+= (*Ptr
<< 16);
498 Align
+= (*Ptr
<< 24);
503 Length
+= (*Ptr
<< 8);
505 Length
+= (*Ptr
<< 16);
507 Length
+= (*Ptr
<< 24);
509 printf(" 32-Bit memory range descriptor\n");
510 printf(" MinBase 0x%lx MaxBase 0x%lx Align 0x%lx Length 0x%lx Flags 0x%02x\n",
511 MinBase
, MaxBase
, Align
,Length
, Info
);
516 PnpDecodeFixedMemory(unsigned char *Ptr
)
529 Base
+= (*Ptr
<< 16);
531 Base
+= (*Ptr
<< 24);
536 Length
+= (*Ptr
<< 8);
538 Length
+= (*Ptr
<< 16);
540 Length
+= (*Ptr
<< 24);
542 printf(" 32-Bit fixed location memory range descriptor\n");
543 printf(" Base 0x%lx Length 0x%lx Flags 0x%02x\n",
548 void PrintDeviceData (PCM_PNP_BIOS_DEVICE_NODE DeviceNode
)
550 unsigned char PnpId
[8];
552 unsigned int TagSize
;
553 unsigned int TagType
;
557 printf ("Node: %x Size %hu (0x%hx)\n",
562 memcpy(Id
, &DeviceNode
->ProductId
, 4);
564 PnpId
[0] = ((Id
[0] >> 2) & 0x1F) + 0x40;
565 PnpId
[1] = ((Id
[0] << 3) & 0x18) +
566 ((Id
[1] >> 5) & 0x07) + 0x40;
567 PnpId
[2] = (Id
[1] & 0x1F) + 0x40;
569 PnpId
[3] = Hex
[(Id
[2] >> 4) & 0xF];
570 PnpId
[4] = Hex
[Id
[2] & 0x0F];
572 PnpId
[5] = Hex
[(Id
[3] >> 4) & 0x0F];
573 PnpId
[6] = Hex
[Id
[3] & 0x0F];
576 printf(" '%s' (%s)\n",
577 PnpId
, GetDeviceName(PnpId
));
579 if (DeviceNode
->Size
> sizeof(CM_PNP_BIOS_DEVICE_NODE
))
581 Ptr
= (unsigned char *)(DeviceNode
+ 1);
586 TagType
= *Ptr
& 0x7F;
590 TagSize
+= (*Ptr
<< 16);
597 PnpDecodeMemory16(Ptr
);
601 PnpDecodeMemory32(Ptr
);
605 PnpDecodeFixedMemory(Ptr
);
609 printf(" Large tag: type %u size %u\n",
617 TagType
= (*Ptr
>> 3) & 0x0F;
618 TagSize
= *Ptr
& 0x07;
624 printf(" Logical device ID\n");
628 printf(" Compatible device ID\n");
640 PnpDecodeIoPort(Ptr
);
644 PnpDecodeFixedIoPort(Ptr
);
647 case 0x0F: /* end tag */
651 printf(" Small tag: type %u size %u\n",
668 int main (int argc
, char *argv
[])
675 PCM_FULL_RESOURCE_DESCRIPTOR lpBuffer
;
676 PCM_PNP_BIOS_INSTALLATION_CHECK lpPnpInst
;
677 PCM_PNP_BIOS_DEVICE_NODE lpDevNode
;
679 DWORD dwDataSize
, dwResourceSize
;
684 if (argc
>1 && (!strcmp (argv
[1],"/S") || !strcmp (argv
[1],"/s")))
689 if (argc
>1 && !strcmp (argv
[1],"/?"))
691 printf ("This utility prints the PnP-nodes from the registry\n");
692 printf ("\"/s\" prevents the \"Press any key\"\n\n");
697 lError
= GetPnpKey(&hPnpKey
);
698 if (lError
!= ERROR_SUCCESS
)
700 printf("Failed to get PnP-BIOS key\n");
706 printf("Found PnP-BIOS key\n");
709 /* Allocate buffer */
711 lpBuffer
= malloc(dwSize
);
713 lError
= RegQueryValueEx(hPnpKey
,
714 "Configuration Data",
719 if (lError
!= ERROR_SUCCESS
)
721 if (lError
== ERROR_MORE_DATA
)
723 printf("Need to resize buffer to %lu\n", dwSize
);
727 printf("Failed to read 'Configuration Data' value\n");
729 RegCloseKey(hPnpKey
);
733 // printf ("Data size: %lu\n", dwSize);
735 RegCloseKey(hPnpKey
);
737 // printf("Resource count %lu\n", lpBuffer->PartialResourceList.Count);
739 if (lpBuffer
->PartialResourceList
.Count
== 0)
741 printf("Invalid resource count!\n");
746 // printf("lpBuffer %p\n", lpBuffer);
748 dwResourceSize
= lpBuffer
->PartialResourceList
.PartialDescriptors
[0].u
.DeviceSpecificData
.DataSize
;
749 // printf("ResourceSize: %lu\n", dwResourceSize);
751 lpPnpInst
= (PCM_PNP_BIOS_INSTALLATION_CHECK
)
752 ((DWORD
)(&lpBuffer
->PartialResourceList
.PartialDescriptors
[0]) +
753 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
));
755 // printf("lpPnpInst %p\n", lpPnpInst);
757 printf("Signature '%.4s'\n", lpPnpInst
->Signature
);
758 if (strncmp(lpPnpInst
->Signature
, "$PnP", 4))
760 printf("Error: Invalid PnP signature\n");
765 // printf("InstCheck length: %lu\n", lpPnpInst->Length);
767 dwDataSize
= sizeof(CM_PNP_BIOS_INSTALLATION_CHECK
);
768 lpDevNode
= (PCM_PNP_BIOS_DEVICE_NODE
)((DWORD
)lpPnpInst
+ sizeof(CM_PNP_BIOS_INSTALLATION_CHECK
));
770 if (lpDevNode
->Size
== 0)
772 printf("Error: Device node size is zero!\n");
777 printf ("Node: %x Size %hu (0x%hx)\n",
787 while (dwDataSize
< dwResourceSize
)
789 if (lpDevNode
->Size
== 0)
792 printf ("Node: %x Size %hu (0x%hx)\n",
797 dwDataSize
+= lpDevNode
->Size
;
798 lpDevNode
= (PCM_PNP_BIOS_DEVICE_NODE
)((DWORD
)lpDevNode
+ lpDevNode
->Size
);
803 printf ("\n Press any key...\n");
811 dwDataSize
= sizeof(CM_PNP_BIOS_INSTALLATION_CHECK
);
812 lpDevNode
= (PCM_PNP_BIOS_DEVICE_NODE
)((DWORD
)lpPnpInst
+ sizeof(CM_PNP_BIOS_INSTALLATION_CHECK
));
814 while (dwDataSize
< dwResourceSize
)
816 PrintDeviceData (lpDevNode
);
820 printf ("\n Press any key...\n");
828 dwDataSize
+= lpDevNode
->Size
;
829 lpDevNode
= (PCM_PNP_BIOS_DEVICE_NODE
)((DWORD
)lpDevNode
+ lpDevNode
->Size
);