4 * Copyright (C) 2003, 2004 Eric Kohl
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #define CLOCK_TICK_RATE (1193182)
31 #define LATCH (CLOCK_TICK_RATE / HZ)
35 #define MOUSE_TYPE_NONE 0
36 /* Microsoft Mouse with 2 buttons */
37 #define MOUSE_TYPE_MICROSOFT 1
38 /* Logitech Mouse with 3 buttons */
39 #define MOUSE_TYPE_LOGITECH 2
40 /* Microsoft Wheel Mouse (aka Z Mouse) */
41 #define MOUSE_TYPE_WHEELZ 3
42 /* Mouse Systems Mouse */
43 #define MOUSE_TYPE_MOUSESYSTEMS 4
48 /* Controller registers. */
49 #define CONTROLLER_REGISTER_STATUS 0x64
50 #define CONTROLLER_REGISTER_CONTROL 0x64
51 #define CONTROLLER_REGISTER_DATA 0x60
53 /* Controller commands. */
54 #define CONTROLLER_COMMAND_READ_MODE 0x20
55 #define CONTROLLER_COMMAND_WRITE_MODE 0x60
56 #define CONTROLLER_COMMAND_GET_VERSION 0xA1
57 #define CONTROLLER_COMMAND_MOUSE_DISABLE 0xA7
58 #define CONTROLLER_COMMAND_MOUSE_ENABLE 0xA8
59 #define CONTROLLER_COMMAND_TEST_MOUSE 0xA9
60 #define CONTROLLER_COMMAND_SELF_TEST 0xAA
61 #define CONTROLLER_COMMAND_KEYBOARD_TEST 0xAB
62 #define CONTROLLER_COMMAND_KEYBOARD_DISABLE 0xAD
63 #define CONTROLLER_COMMAND_KEYBOARD_ENABLE 0xAE
64 #define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER 0xD3
65 #define CONTROLLER_COMMAND_WRITE_MOUSE 0xD4
67 /* Controller status */
68 #define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL 0x01
69 #define CONTROLLER_STATUS_INPUT_BUFFER_FULL 0x02
70 #define CONTROLLER_STATUS_SELF_TEST 0x04
71 #define CONTROLLER_STATUS_COMMAND 0x08
72 #define CONTROLLER_STATUS_UNLOCKED 0x10
73 #define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL 0x20
74 #define CONTROLLER_STATUS_GENERAL_TIMEOUT 0x40
75 #define CONTROLLER_STATUS_PARITY_ERROR 0x80
76 #define AUX_STATUS_OUTPUT_BUFFER_FULL (CONTROLLER_STATUS_OUTPUT_BUFFER_FULL | \
77 CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL)
79 /* Timeout in ms for sending to keyboard controller. */
80 #define CONTROLLER_TIMEOUT 250
83 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA
86 ULONG NumberOfCylinders
;
87 ULONG SectorsPerTrack
;
89 } CM_DISK_GEOMETRY_DEVICE_DATA
, *PCM_DISK_GEOMETRY_DEVICE_DATA
;
92 typedef struct _CM_PNP_BIOS_DEVICE_NODE
98 USHORT DeviceAttributes
;
99 } __attribute__((packed
)) CM_PNP_BIOS_DEVICE_NODE
, *PCM_PNP_BIOS_DEVICE_NODE
;
102 typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK
109 ULONG EventFlagAddress
;
110 USHORT RealModeEntryOffset
;
111 USHORT RealModeEntrySegment
;
112 USHORT ProtectedModeEntryOffset
;
113 ULONG ProtectedModeCodeBaseAddress
;
115 USHORT RealModeDataBaseAddress
;
116 ULONG ProtectedModeDataBaseAddress
;
117 } __attribute__((packed
)) CM_PNP_BIOS_INSTALLATION_CHECK
, *PCM_PNP_BIOS_INSTALLATION_CHECK
;
120 static WCHAR Hex
[] = L
"0123456789ABCDEF";
121 static unsigned int delay_count
= 1;
124 /* FUNCTIONS ****************************************************************/
128 __StallExecutionProcessor(ULONG Loops
)
130 register unsigned int i
;
131 for (i
= 0; i
< Loops
; i
++);
135 VOID
StallExecutionProcessor(ULONG Microseconds
)
137 ULONGLONG LoopCount
= ((ULONGLONG
)delay_count
* (ULONGLONG
)Microseconds
) / 1000ULL;
138 __StallExecutionProcessor((ULONG
)LoopCount
);
147 WRITE_PORT_UCHAR((PUCHAR
)0x43, 0x00);
148 Count
= READ_PORT_UCHAR((PUCHAR
)0x40);
149 Count
|= READ_PORT_UCHAR((PUCHAR
)0x40) << 8;
156 WaitFor8254Wraparound(VOID
)
159 ULONG PrevCount
= ~0;
162 CurCount
= Read8254Timer();
166 PrevCount
= CurCount
;
167 CurCount
= Read8254Timer();
168 Delta
= CurCount
- PrevCount
;
171 * This limit for delta seems arbitrary, but it isn't, it's
172 * slightly above the level of error a buggy Mercury/Neptune
173 * chipset timer can cause.
181 HalpCalibrateStallExecution(VOID
)
187 /* Initialise timer interrupt with MILLISECOND ms interval */
188 WRITE_PORT_UCHAR((PUCHAR
)0x43, 0x34); /* binary, mode 2, LSB/MSB, ch 0 */
189 WRITE_PORT_UCHAR((PUCHAR
)0x40, LATCH
& 0xff); /* LSB */
190 WRITE_PORT_UCHAR((PUCHAR
)0x40, LATCH
>> 8); /* MSB */
192 /* Stage 1: Coarse calibration */
194 WaitFor8254Wraparound();
199 delay_count
<<= 1; /* Next delay count to try */
201 WaitFor8254Wraparound();
203 __StallExecutionProcessor(delay_count
); /* Do the delay */
205 CurCount
= Read8254Timer();
206 } while (CurCount
> LATCH
/ 2);
208 delay_count
>>= 1; /* Get bottom value for delay */
210 /* Stage 2: Fine calibration */
212 calib_bit
= delay_count
; /* Which bit are we going to test */
214 for(i
=0;i
<PRECISION
;i
++) {
215 calib_bit
>>= 1; /* Next bit to calibrate */
216 if(!calib_bit
) break; /* If we have done all bits, stop */
218 delay_count
|= calib_bit
; /* Set the bit in delay_count */
220 WaitFor8254Wraparound();
222 __StallExecutionProcessor(delay_count
); /* Do the delay */
224 CurCount
= Read8254Timer();
225 if (CurCount
<= LATCH
/ 2) /* If a tick has passed, turn the */
226 delay_count
&= ~calib_bit
; /* calibrated bit back off */
229 /* We're finished: Do the finishing touches */
230 delay_count
/= (MILLISEC
/ 2); /* Calculate delay_count for 1ms */
235 SetComponentInformation(FRLDRHKEY ComponentKey
,
240 CM_COMPONENT_INFORMATION CompInfo
;
243 CompInfo
.Flags
= Flags
;
244 CompInfo
.Version
= 0;
246 CompInfo
.Affinity
= Affinity
;
248 /* Set 'Component Information' value */
249 Error
= RegSetValue(ComponentKey
,
250 L
"Component Information",
253 sizeof(CM_COMPONENT_INFORMATION
));
254 if (Error
!= ERROR_SUCCESS
)
256 DbgPrint((DPRINT_HWDETECT
, "RegSetValue() failed (Error %u)\n", (int)Error
));
262 DetectPnpBios(FRLDRHKEY SystemKey
, ULONG
*BusNumber
)
264 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
265 PCM_PNP_BIOS_DEVICE_NODE DeviceNode
;
266 PCM_PNP_BIOS_INSTALLATION_CHECK InstData
;
273 ULONG FoundNodeCount
;
280 InstData
= (PCM_PNP_BIOS_INSTALLATION_CHECK
)PnpBiosSupported();
281 if (InstData
== NULL
|| strncmp((CHAR
*)InstData
->Signature
, "$PnP", 4))
283 DbgPrint((DPRINT_HWDETECT
, "PnP-BIOS not supported\n"));
286 DbgPrint((DPRINT_HWDETECT
, "Signature '%c%c%c%c'\n",
287 InstData
->Signature
[0], InstData
->Signature
[1],
288 InstData
->Signature
[2], InstData
->Signature
[3]));
291 x
= PnpBiosGetDeviceNodeCount(&NodeSize
, &NodeCount
);
292 NodeCount
&= 0xFF; // needed since some fscked up BIOSes return
293 // wrong info (e.g. Mac Virtual PC)
294 // e.g. look: http://my.execpc.com/~geezer/osd/pnp/pnp16.c
295 if (x
!= 0 || NodeSize
== 0 || NodeCount
== 0)
297 DbgPrint((DPRINT_HWDETECT
, "PnP-BIOS failed to enumerate device nodes\n"));
300 DbgPrint((DPRINT_HWDETECT
, "PnP-BIOS supported\n"));
301 DbgPrint((DPRINT_HWDETECT
, "MaxNodeSize %u NodeCount %u\n", NodeSize
, NodeCount
));
302 DbgPrint((DPRINT_HWDETECT
, "Estimated buffer size %u\n", NodeSize
* NodeCount
));
304 /* Create new bus key */
306 L
"MultifunctionAdapter\\%u", *BusNumber
);
307 Error
= RegCreateKey(SystemKey
,
310 if (Error
!= ERROR_SUCCESS
)
312 DbgPrint((DPRINT_HWDETECT
, "RegCreateKey() failed (Error %u)\n", (int)Error
));
316 /* Increment bus number */
319 /* Set 'Component Information' value similar to my NT4 box */
320 SetComponentInformation(BusKey
,
325 /* Set 'Identifier' value */
326 Error
= RegSetValue(BusKey
,
331 if (Error
!= ERROR_SUCCESS
)
333 DbgPrint((DPRINT_HWDETECT
, "RegSetValue() failed (Error %u)\n", (int)Error
));
337 /* Set 'Configuration Data' value */
338 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) + (NodeSize
* NodeCount
);
339 FullResourceDescriptor
= MmAllocateMemory(Size
);
340 if (FullResourceDescriptor
== NULL
)
342 DbgPrint((DPRINT_HWDETECT
,
343 "Failed to allocate resource descriptor\n"));
346 memset(FullResourceDescriptor
, 0, Size
);
348 /* Initialize resource descriptor */
349 FullResourceDescriptor
->InterfaceType
= Internal
;
350 FullResourceDescriptor
->BusNumber
= 0;
351 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
352 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].Type
=
353 CmResourceTypeDeviceSpecific
;
354 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].ShareDisposition
=
355 CmResourceShareUndetermined
;
357 Ptr
= (char *)(((ULONG_PTR
)&FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0]) +
358 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
));
360 /* Set instalation check data */
361 memcpy (Ptr
, InstData
, sizeof(CM_PNP_BIOS_INSTALLATION_CHECK
));
362 Ptr
+= sizeof(CM_PNP_BIOS_INSTALLATION_CHECK
);
364 /* Copy device nodes */
366 PnpBufferSize
= sizeof(CM_PNP_BIOS_INSTALLATION_CHECK
);
367 for (i
= 0; i
< 0xFF; i
++)
369 NodeNumber
= (UCHAR
)i
;
371 x
= PnpBiosGetDeviceNode(&NodeNumber
, (PVOID
)DISKREADBUFFER
);
374 DeviceNode
= (PCM_PNP_BIOS_DEVICE_NODE
)DISKREADBUFFER
;
376 DbgPrint((DPRINT_HWDETECT
,
377 "Node: %u Size %u (0x%x)\n",
386 Ptr
+= DeviceNode
->Size
;
387 PnpBufferSize
+= DeviceNode
->Size
;
390 if (FoundNodeCount
>= NodeCount
)
395 /* Set real data size */
396 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].u
.DeviceSpecificData
.DataSize
=
398 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) + PnpBufferSize
;
400 DbgPrint((DPRINT_HWDETECT
, "Real buffer size: %u\n", PnpBufferSize
));
401 DbgPrint((DPRINT_HWDETECT
, "Resource size: %u\n", Size
));
403 /* Set 'Configuration Data' value */
404 Error
= RegSetValue(BusKey
,
405 L
"Configuration Data",
406 REG_FULL_RESOURCE_DESCRIPTOR
,
407 (PCHAR
) FullResourceDescriptor
,
409 MmFreeMemory(FullResourceDescriptor
);
410 if (Error
!= ERROR_SUCCESS
)
412 DbgPrint((DPRINT_HWDETECT
,
413 "RegSetValue(Configuration Data) failed (Error %u)\n",
421 SetHarddiskConfigurationData(FRLDRHKEY DiskKey
,
424 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
425 PCM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
;
426 EXTENDED_GEOMETRY ExtGeometry
;
431 /* Set 'Configuration Data' value */
432 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
433 sizeof(CM_DISK_GEOMETRY_DEVICE_DATA
);
434 FullResourceDescriptor
= MmAllocateMemory(Size
);
435 if (FullResourceDescriptor
== NULL
)
437 DbgPrint((DPRINT_HWDETECT
,
438 "Failed to allocate a full resource descriptor\n"));
442 memset(FullResourceDescriptor
, 0, Size
);
443 FullResourceDescriptor
->InterfaceType
= InterfaceTypeUndefined
;
444 FullResourceDescriptor
->BusNumber
= 0;
445 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
446 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].Type
=
447 CmResourceTypeDeviceSpecific
;
448 // FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].ShareDisposition =
449 // FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].Flags =
450 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].u
.DeviceSpecificData
.DataSize
=
451 sizeof(CM_DISK_GEOMETRY_DEVICE_DATA
);
453 /* Get pointer to geometry data */
454 DiskGeometry
= (PVOID
)(((ULONG_PTR
)FullResourceDescriptor
) + sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
456 /* Get the disk geometry */
457 ExtGeometry
.Size
= sizeof(EXTENDED_GEOMETRY
);
458 if (DiskGetExtendedDriveParameters(DriveNumber
, &ExtGeometry
, ExtGeometry
.Size
))
460 DiskGeometry
->BytesPerSector
= ExtGeometry
.BytesPerSector
;
461 DiskGeometry
->NumberOfCylinders
= ExtGeometry
.Cylinders
;
462 DiskGeometry
->SectorsPerTrack
= ExtGeometry
.SectorsPerTrack
;
463 DiskGeometry
->NumberOfHeads
= ExtGeometry
.Heads
;
465 else if(MachDiskGetDriveGeometry(DriveNumber
, &Geometry
))
467 DiskGeometry
->BytesPerSector
= Geometry
.BytesPerSector
;
468 DiskGeometry
->NumberOfCylinders
= Geometry
.Cylinders
;
469 DiskGeometry
->SectorsPerTrack
= Geometry
.Sectors
;
470 DiskGeometry
->NumberOfHeads
= Geometry
.Heads
;
474 DbgPrint((DPRINT_HWDETECT
, "Reading disk geometry failed\n"));
475 MmFreeMemory(FullResourceDescriptor
);
478 DbgPrint((DPRINT_HWDETECT
,
479 "Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
481 DiskGeometry
->NumberOfCylinders
,
482 DiskGeometry
->NumberOfHeads
,
483 DiskGeometry
->SectorsPerTrack
,
484 DiskGeometry
->BytesPerSector
));
486 Error
= RegSetValue(DiskKey
,
487 L
"Configuration Data",
488 REG_FULL_RESOURCE_DESCRIPTOR
,
489 (PCHAR
) FullResourceDescriptor
,
491 MmFreeMemory(FullResourceDescriptor
);
492 if (Error
!= ERROR_SUCCESS
)
494 DbgPrint((DPRINT_HWDETECT
,
495 "RegSetValue(Configuration Data) failed (Error %u)\n",
502 SetHarddiskIdentifier(FRLDRHKEY DiskKey
,
505 PMASTER_BOOT_RECORD Mbr
;
510 WCHAR Identifier
[20];
514 if (!MachDiskReadLogicalSectors(DriveNumber
, 0ULL, 1, (PVOID
)DISKREADBUFFER
))
516 DbgPrint((DPRINT_HWDETECT
, "Reading MBR failed\n"));
520 Buffer
= (ULONG
*)DISKREADBUFFER
;
521 Mbr
= (PMASTER_BOOT_RECORD
)DISKREADBUFFER
;
523 Signature
= Mbr
->Signature
;
524 DbgPrint((DPRINT_HWDETECT
, "Signature: %x\n", Signature
));
526 /* Calculate the MBR checksum */
528 for (i
= 0; i
< 128; i
++)
530 Checksum
+= Buffer
[i
];
532 Checksum
= ~Checksum
+ 1;
533 DbgPrint((DPRINT_HWDETECT
, "Checksum: %x\n", Checksum
));
535 /* Convert checksum and signature to identifier string */
536 Identifier
[0] = Hex
[(Checksum
>> 28) & 0x0F];
537 Identifier
[1] = Hex
[(Checksum
>> 24) & 0x0F];
538 Identifier
[2] = Hex
[(Checksum
>> 20) & 0x0F];
539 Identifier
[3] = Hex
[(Checksum
>> 16) & 0x0F];
540 Identifier
[4] = Hex
[(Checksum
>> 12) & 0x0F];
541 Identifier
[5] = Hex
[(Checksum
>> 8) & 0x0F];
542 Identifier
[6] = Hex
[(Checksum
>> 4) & 0x0F];
543 Identifier
[7] = Hex
[Checksum
& 0x0F];
544 Identifier
[8] = L
'-';
545 Identifier
[9] = Hex
[(Signature
>> 28) & 0x0F];
546 Identifier
[10] = Hex
[(Signature
>> 24) & 0x0F];
547 Identifier
[11] = Hex
[(Signature
>> 20) & 0x0F];
548 Identifier
[12] = Hex
[(Signature
>> 16) & 0x0F];
549 Identifier
[13] = Hex
[(Signature
>> 12) & 0x0F];
550 Identifier
[14] = Hex
[(Signature
>> 8) & 0x0F];
551 Identifier
[15] = Hex
[(Signature
>> 4) & 0x0F];
552 Identifier
[16] = Hex
[Signature
& 0x0F];
553 Identifier
[17] = L
'-';
554 Identifier
[18] = L
'A';
556 DbgPrint((DPRINT_HWDETECT
, "Identifier: %S\n", Identifier
));
559 Error
= RegSetValue(DiskKey
,
564 if (Error
!= ERROR_SUCCESS
)
566 DbgPrint((DPRINT_HWDETECT
,
567 "RegSetValue(Identifier) failed (Error %u)\n",
574 DetectBiosDisks(FRLDRHKEY SystemKey
,
577 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
578 PCM_INT13_DRIVE_PARAMETER Int13Drives
;
588 /* Count the number of visible drives */
589 DiskReportError(FALSE
);
592 /* There are some really broken BIOSes out there. There are even BIOSes
593 * that happily report success when you ask them to read from non-existent
594 * harddisks. So, we set the buffer to known contents first, then try to
595 * read. If the BIOS reports success but the buffer contents haven't
596 * changed then we fail anyway */
597 memset((PVOID
) DISKREADBUFFER
, 0xcd, 512);
598 while (MachDiskReadLogicalSectors(0x80 + DiskCount
, 0ULL, 1, (PVOID
)DISKREADBUFFER
))
601 for (i
= 0; ! Changed
&& i
< 512; i
++)
603 Changed
= ((PUCHAR
)DISKREADBUFFER
)[i
] != 0xcd;
607 DbgPrint((DPRINT_HWDETECT
, "BIOS reports success for disk %d but data didn't change\n",
612 memset((PVOID
) DISKREADBUFFER
, 0xcd, 512);
614 DiskReportError(TRUE
);
615 DbgPrint((DPRINT_HWDETECT
, "BIOS reports %d harddisk%s\n",
616 (int)DiskCount
, (DiskCount
== 1) ? "": "s"));
618 /* Allocate resource descriptor */
619 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
620 sizeof(CM_INT13_DRIVE_PARAMETER
) * DiskCount
;
621 FullResourceDescriptor
= MmAllocateMemory(Size
);
622 if (FullResourceDescriptor
== NULL
)
624 DbgPrint((DPRINT_HWDETECT
,
625 "Failed to allocate resource descriptor\n"));
629 /* Initialize resource descriptor */
630 memset(FullResourceDescriptor
, 0, Size
);
631 FullResourceDescriptor
->InterfaceType
= InterfaceTypeUndefined
;
632 FullResourceDescriptor
->BusNumber
= -1;
633 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
634 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].Type
=
635 CmResourceTypeDeviceSpecific
;
636 // FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].ShareDisposition =
637 // FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].Flags =
638 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].u
.DeviceSpecificData
.DataSize
=
639 sizeof(CM_INT13_DRIVE_PARAMETER
) * DiskCount
;
641 /* Get harddisk Int13 geometry data */
642 Int13Drives
= (PVOID
)(((ULONG_PTR
)FullResourceDescriptor
) + sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
643 for (i
= 0; i
< DiskCount
; i
++)
645 if (MachDiskGetDriveGeometry(0x80 + i
, &Geometry
))
647 Int13Drives
[i
].DriveSelect
= 0x80 + i
;
648 Int13Drives
[i
].MaxCylinders
= Geometry
.Cylinders
- 1;
649 Int13Drives
[i
].SectorsPerTrack
= Geometry
.Sectors
;
650 Int13Drives
[i
].MaxHeads
= Geometry
.Heads
- 1;
651 Int13Drives
[i
].NumberDrives
= DiskCount
;
653 DbgPrint((DPRINT_HWDETECT
,
654 "Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
656 Geometry
.Cylinders
- 1,
659 Geometry
.BytesPerSector
));
663 /* Set 'Configuration Data' value */
664 Error
= RegSetValue(SystemKey
,
665 L
"Configuration Data",
666 REG_FULL_RESOURCE_DESCRIPTOR
,
667 (PCHAR
) FullResourceDescriptor
,
669 MmFreeMemory(FullResourceDescriptor
);
670 if (Error
!= ERROR_SUCCESS
)
672 DbgPrint((DPRINT_HWDETECT
,
673 "RegSetValue(Configuration Data) failed (Error %u)\n",
678 /* Create and fill subkey for each harddisk */
679 for (i
= 0; i
< DiskCount
; i
++)
681 /* Create disk key */
683 L
"DiskController\\0\\DiskPeripheral\\%u",
686 Error
= RegCreateKey(BusKey
,
689 if (Error
!= ERROR_SUCCESS
)
691 DbgPrint((DPRINT_HWDETECT
, "Failed to create drive key\n"));
694 DbgPrint((DPRINT_HWDETECT
, "Created key: %S\n", Buffer
));
696 /* Set disk values */
697 SetHarddiskConfigurationData(DiskKey
, 0x80 + i
);
698 SetHarddiskIdentifier(DiskKey
, 0x80 + i
);
708 WRITE_PORT_UCHAR((PUCHAR
)0x70, 0x10);
709 Data
= READ_PORT_UCHAR((PUCHAR
)0x71);
711 return ((Data
& 0xF0) ? 1 : 0) + ((Data
& 0x0F) ? 1 : 0);
716 GetFloppyType(UCHAR DriveNumber
)
720 WRITE_PORT_UCHAR((PUCHAR
)0x70, 0x10);
721 Data
= READ_PORT_UCHAR((PUCHAR
)0x71);
723 if (DriveNumber
== 0)
725 else if (DriveNumber
== 1)
735 PUSHORT SegPtr
= (PUSHORT
)0x7A;
736 PUSHORT OfsPtr
= (PUSHORT
)0x78;
738 return (PVOID
)((ULONG_PTR
)(((ULONG
)(*SegPtr
)) << 4) + (ULONG
)(*OfsPtr
));
743 DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey
)
745 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
746 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
747 PCM_FLOPPY_DEVICE_DATA FloppyData
;
749 WCHAR Identifier
[20];
750 FRLDRHKEY PeripheralKey
;
755 ULONG MaxDensity
[6] = {0, 360, 1200, 720, 1440, 2880};
758 for (FloppyNumber
= 0; FloppyNumber
< 2; FloppyNumber
++)
760 FloppyType
= GetFloppyType(FloppyNumber
);
762 if ((FloppyType
> 5) || (FloppyType
== 0))
765 DiskResetController(FloppyNumber
);
767 Ptr
= GetInt1eTable();
769 swprintf(KeyName
, L
"FloppyDiskPeripheral\\%u", FloppyNumber
);
771 Error
= RegCreateKey(ControllerKey
,
774 if (Error
!= ERROR_SUCCESS
)
776 DbgPrint((DPRINT_HWDETECT
, "Failed to create peripheral key\n"));
780 DbgPrint((DPRINT_HWDETECT
, "Created key: %S\n", KeyName
));
782 /* Set 'ComponentInformation' value */
783 SetComponentInformation(PeripheralKey
,
788 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
789 sizeof(CM_FLOPPY_DEVICE_DATA
);
790 FullResourceDescriptor
= MmAllocateMemory(Size
);
791 if (FullResourceDescriptor
== NULL
)
793 DbgPrint((DPRINT_HWDETECT
,
794 "Failed to allocate resource descriptor\n"));
798 memset(FullResourceDescriptor
, 0, Size
);
799 FullResourceDescriptor
->InterfaceType
= Isa
;
800 FullResourceDescriptor
->BusNumber
= 0;
801 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
803 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
804 PartialDescriptor
->Type
= CmResourceTypeDeviceSpecific
;
805 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
806 PartialDescriptor
->u
.DeviceSpecificData
.DataSize
= sizeof(CM_FLOPPY_DEVICE_DATA
);
808 FloppyData
= (PVOID
)(((ULONG_PTR
)FullResourceDescriptor
) + sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
809 FloppyData
->Version
= 2;
810 FloppyData
->Revision
= 0;
811 FloppyData
->MaxDensity
= MaxDensity
[FloppyType
];
812 FloppyData
->MountDensity
= 0;
813 RtlCopyMemory(&FloppyData
->StepRateHeadUnloadTime
,
816 FloppyData
->MaximumTrackValue
= (FloppyType
== 1) ? 39 : 79;
817 FloppyData
->DataTransferRate
= 0;
819 /* Set 'Configuration Data' value */
820 Error
= RegSetValue(PeripheralKey
,
821 L
"Configuration Data",
822 REG_FULL_RESOURCE_DESCRIPTOR
,
823 (PCHAR
) FullResourceDescriptor
,
825 MmFreeMemory(FullResourceDescriptor
);
826 if (Error
!= ERROR_SUCCESS
)
828 DbgPrint((DPRINT_HWDETECT
,
829 "RegSetValue(Configuration Data) failed (Error %u)\n",
834 /* Set 'Identifier' value */
835 swprintf(Identifier
, L
"FLOPPY%u", FloppyNumber
+ 1);
836 Error
= RegSetValue(PeripheralKey
,
840 (wcslen(Identifier
) + 1) * sizeof(WCHAR
));
841 if (Error
!= ERROR_SUCCESS
)
843 DbgPrint((DPRINT_HWDETECT
,
844 "RegSetValue() failed (Error %u)\n",
852 DetectBiosFloppyController(FRLDRHKEY SystemKey
,
855 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
856 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
857 FRLDRHKEY ControllerKey
;
862 FloppyCount
= GetFloppyCount();
863 DbgPrint((DPRINT_HWDETECT
,
864 "Floppy count: %u\n",
867 if (FloppyCount
== 0)
870 Error
= RegCreateKey(BusKey
,
871 L
"DiskController\\0",
873 if (Error
!= ERROR_SUCCESS
)
875 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
879 DbgPrint((DPRINT_HWDETECT
, "Created key: DiskController\\0\n"));
881 /* Set 'ComponentInformation' value */
882 SetComponentInformation(ControllerKey
,
887 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
888 2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
889 FullResourceDescriptor
= MmAllocateMemory(Size
);
890 if (FullResourceDescriptor
== NULL
)
892 DbgPrint((DPRINT_HWDETECT
,
893 "Failed to allocate resource descriptor\n"));
896 memset(FullResourceDescriptor
, 0, Size
);
898 /* Initialize resource descriptor */
899 FullResourceDescriptor
->InterfaceType
= Isa
;
900 FullResourceDescriptor
->BusNumber
= 0;
901 FullResourceDescriptor
->PartialResourceList
.Count
= 3;
904 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
905 PartialDescriptor
->Type
= CmResourceTypePort
;
906 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
907 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
908 PartialDescriptor
->u
.Port
.Start
.LowPart
= 0x03F0;
909 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
910 PartialDescriptor
->u
.Port
.Length
= 8;
913 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
914 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
915 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
916 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
917 PartialDescriptor
->u
.Interrupt
.Level
= 6;
918 PartialDescriptor
->u
.Interrupt
.Vector
= 6;
919 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
921 /* Set DMA channel */
922 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[2];
923 PartialDescriptor
->Type
= CmResourceTypeDma
;
924 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
925 PartialDescriptor
->Flags
= 0;
926 PartialDescriptor
->u
.Dma
.Channel
= 2;
927 PartialDescriptor
->u
.Dma
.Port
= 0;
929 /* Set 'Configuration Data' value */
930 Error
= RegSetValue(ControllerKey
,
931 L
"Configuration Data",
932 REG_FULL_RESOURCE_DESCRIPTOR
,
933 (PCHAR
) FullResourceDescriptor
,
935 MmFreeMemory(FullResourceDescriptor
);
936 if (Error
!= ERROR_SUCCESS
)
938 DbgPrint((DPRINT_HWDETECT
,
939 "RegSetValue(Configuration Data) failed (Error %u)\n",
944 DetectBiosFloppyPeripheral(ControllerKey
);
949 InitializeSerialPort(ULONG Port
,
952 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 3, 0x80); /* set DLAB on */
953 WRITE_PORT_UCHAR((PUCHAR
)Port
, 0x60); /* speed LO byte */
954 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 1, 0); /* speed HI byte */
955 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 3, LineControl
);
956 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 1, 0); /* set comm and DLAB to 0 */
957 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 4, 0x09); /* DR int enable */
958 READ_PORT_UCHAR((PUCHAR
)Port
+ 5); /* clear error bits */
963 DetectSerialMouse(ULONG Port
)
970 /* Shutdown mouse or something like that */
971 LineControl
= READ_PORT_UCHAR((PUCHAR
)Port
+ 4);
972 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 4, (LineControl
& ~0x02) | 0x01);
973 StallExecutionProcessor(100000);
976 while (READ_PORT_UCHAR((PUCHAR
)Port
+ 5) & 0x01)
977 READ_PORT_UCHAR((PUCHAR
)Port
);
980 * Send modem control with 'Data Terminal Ready', 'Request To Send' and
981 * 'Output Line 2' message. This enables mouse to identify.
983 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 4, 0x0b);
985 /* Wait 10 milliseconds for the mouse getting ready */
986 StallExecutionProcessor(10000);
988 /* Read first four bytes, which contains Microsoft Mouse signs */
989 for (i
= 0; i
< 4; i
++)
991 while (((READ_PORT_UCHAR((PUCHAR
)Port
+ 5) & 1) == 0) && (TimeOut
> 0))
993 StallExecutionProcessor(1000);
996 return MOUSE_TYPE_NONE
;
998 Buffer
[i
] = READ_PORT_UCHAR((PUCHAR
)Port
);
1001 DbgPrint((DPRINT_HWDETECT
,
1002 "Mouse data: %x %x %x %x\n",
1003 Buffer
[0],Buffer
[1],Buffer
[2],Buffer
[3]));
1005 /* Check that four bytes for signs */
1006 for (i
= 0; i
< 4; ++i
)
1008 if (Buffer
[i
] == 'B')
1010 /* Sign for Microsoft Ballpoint */
1011 // DbgPrint("Microsoft Ballpoint device detected\n");
1012 // DbgPrint("THIS DEVICE IS NOT SUPPORTED, YET\n");
1013 return MOUSE_TYPE_NONE
;
1015 else if (Buffer
[i
] == 'M')
1017 /* Sign for Microsoft Mouse protocol followed by button specifier */
1020 /* Overflow Error */
1021 return MOUSE_TYPE_NONE
;
1024 switch (Buffer
[i
+ 1])
1027 DbgPrint((DPRINT_HWDETECT
,
1028 "Microsoft Mouse with 3-buttons detected\n"));
1029 return MOUSE_TYPE_LOGITECH
;
1032 DbgPrint((DPRINT_HWDETECT
,
1033 "Microsoft Wheel Mouse detected\n"));
1034 return MOUSE_TYPE_WHEELZ
;
1038 DbgPrint((DPRINT_HWDETECT
,
1039 "Microsoft Mouse with 2-buttons detected\n"));
1040 return MOUSE_TYPE_MICROSOFT
;
1045 return MOUSE_TYPE_NONE
;
1050 GetSerialMousePnpId(ULONG Port
, char *Buffer
)
1057 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 4, 0x09);
1059 /* Wait 10 milliseconds for the mouse getting ready */
1060 StallExecutionProcessor(10000);
1062 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 4, 0x0b);
1064 StallExecutionProcessor(10000);
1069 while (((READ_PORT_UCHAR((PUCHAR
)Port
+ 5) & 1) == 0) && (TimeOut
> 0))
1071 StallExecutionProcessor(1000);
1079 c
= READ_PORT_UCHAR((PUCHAR
)Port
);
1080 if (c
== 0x08 || c
== 0x28)
1090 while (((READ_PORT_UCHAR((PUCHAR
)Port
+ 5) & 1) == 0) && (TimeOut
> 0))
1092 StallExecutionProcessor(1000);
1097 c
= READ_PORT_UCHAR((PUCHAR
)Port
);
1110 DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey
,
1113 CM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1115 WCHAR Identifier
[256];
1116 FRLDRHKEY PeripheralKey
;
1124 DbgPrint((DPRINT_HWDETECT
,
1125 "DetectSerialPointerPeripheral()\n"));
1129 InitializeSerialPort(Base
, 2);
1130 MouseType
= DetectSerialMouse(Base
);
1132 if (MouseType
!= MOUSE_TYPE_NONE
)
1134 Length
= GetSerialMousePnpId(Base
, Buffer
);
1135 DbgPrint((DPRINT_HWDETECT
,
1136 "PnP ID length: %u\n",
1141 /* Convert PnP sting to ASCII */
1142 if (Buffer
[0] == 0x08)
1144 for (i
= 0; i
< Length
; i
++)
1149 DbgPrint((DPRINT_HWDETECT
,
1150 "PnP ID string: %s\n",
1153 /* Copy PnpId string */
1154 for (i
= 0; i
< 7; i
++)
1156 Identifier
[i
] = Buffer
[3+i
];
1158 memcpy(&Identifier
[7],
1162 /* Skip device serial number */
1164 if (Buffer
[i
] == '\\')
1166 for (j
= ++i
; i
< Length
; ++i
)
1168 if (Buffer
[i
] == '\\')
1175 /* Skip PnP class */
1176 if (Buffer
[i
] == '\\')
1178 for (j
= ++i
; i
< Length
; ++i
)
1180 if (Buffer
[i
] == '\\')
1188 /* Skip compatible PnP Id */
1189 if (Buffer
[i
] == '\\')
1191 for (j
= ++i
; i
< Length
; ++i
)
1193 if (Buffer
[i
] == '\\')
1196 if (Buffer
[j
] == '*')
1202 /* Get product description */
1203 if (Buffer
[i
] == '\\')
1205 for (j
= ++i
; i
< Length
; ++i
)
1207 if (Buffer
[i
] == ';')
1214 for (k
= 0; k
< i
- j
; k
++)
1216 Identifier
[k
+ 10] = Buffer
[k
+ j
];
1218 Identifier
[10 + (i
-j
)] = 0;
1222 DbgPrint((DPRINT_HWDETECT
,
1223 "Identifier string: %S\n",
1227 if (Length
== 0 || wcslen(Identifier
) < 11)
1231 case MOUSE_TYPE_LOGITECH
:
1233 L
"LOGITECH SERIAL MOUSE");
1236 case MOUSE_TYPE_WHEELZ
:
1238 L
"MICROSOFT SERIAL MOUSE WITH WHEEL");
1241 case MOUSE_TYPE_MICROSOFT
:
1244 L
"MICROSOFT SERIAL MOUSE");
1249 /* Create 'PointerPeripheral' key */
1250 Error
= RegCreateKey(ControllerKey
,
1251 L
"PointerPeripheral\\0",
1253 if (Error
!= ERROR_SUCCESS
)
1255 DbgPrint((DPRINT_HWDETECT
,
1256 "Failed to create peripheral key\n"));
1259 DbgPrint((DPRINT_HWDETECT
,
1260 "Created key: PointerPeripheral\\0\n"));
1262 /* Set 'ComponentInformation' value */
1263 SetComponentInformation(PeripheralKey
,
1268 /* Set 'Configuration Data' value */
1269 memset(&FullResourceDescriptor
, 0, sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1270 FullResourceDescriptor
.InterfaceType
= Isa
;
1271 FullResourceDescriptor
.BusNumber
= 0;
1272 FullResourceDescriptor
.PartialResourceList
.Count
= 0;
1274 Error
= RegSetValue(PeripheralKey
,
1275 L
"Configuration Data",
1276 REG_FULL_RESOURCE_DESCRIPTOR
,
1277 (PCHAR
)&FullResourceDescriptor
,
1278 sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) -
1279 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
));
1280 if (Error
!= ERROR_SUCCESS
)
1282 DbgPrint((DPRINT_HWDETECT
,
1283 "RegSetValue(Configuration Data) failed (Error %u)\n",
1287 /* Set 'Identifier' value */
1288 Error
= RegSetValue(PeripheralKey
,
1292 (wcslen(Identifier
) + 1) * sizeof(WCHAR
));
1293 if (Error
!= ERROR_SUCCESS
)
1295 DbgPrint((DPRINT_HWDETECT
,
1296 "RegSetValue() failed (Error %u)\n",
1304 DetectSerialPorts(FRLDRHKEY BusKey
)
1306 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1307 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1308 PCM_SERIAL_DEVICE_DATA SerialDeviceData
;
1309 ULONG Irq
[4] = {4, 3, 4, 3};
1313 ULONG ControllerNumber
= 0;
1314 FRLDRHKEY ControllerKey
;
1319 DbgPrint((DPRINT_HWDETECT
, "DetectSerialPorts()\n"));
1321 ControllerNumber
= 0;
1322 BasePtr
= (PUSHORT
)0x400;
1323 for (i
= 0; i
< 4; i
++, BasePtr
++)
1325 Base
= (ULONG
)*BasePtr
;
1329 DbgPrint((DPRINT_HWDETECT
,
1330 "Found COM%u port at 0x%x\n",
1334 /* Create controller key */
1336 L
"SerialController\\%u",
1339 Error
= RegCreateKey(BusKey
,
1342 if (Error
!= ERROR_SUCCESS
)
1344 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1347 DbgPrint((DPRINT_HWDETECT
, "Created key: %S\n", Buffer
));
1349 /* Set 'ComponentInformation' value */
1350 SetComponentInformation(ControllerKey
,
1355 /* Build full device descriptor */
1356 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
1357 2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
) +
1358 sizeof(CM_SERIAL_DEVICE_DATA
);
1359 FullResourceDescriptor
= MmAllocateMemory(Size
);
1360 if (FullResourceDescriptor
== NULL
)
1362 DbgPrint((DPRINT_HWDETECT
,
1363 "Failed to allocate resource descriptor\n"));
1366 memset(FullResourceDescriptor
, 0, Size
);
1368 /* Initialize resource descriptor */
1369 FullResourceDescriptor
->InterfaceType
= Isa
;
1370 FullResourceDescriptor
->BusNumber
= 0;
1371 FullResourceDescriptor
->PartialResourceList
.Count
= 3;
1374 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1375 PartialDescriptor
->Type
= CmResourceTypePort
;
1376 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1377 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1378 PartialDescriptor
->u
.Port
.Start
.LowPart
= Base
;
1379 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1380 PartialDescriptor
->u
.Port
.Length
= 7;
1383 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
1384 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
1385 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1386 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1387 PartialDescriptor
->u
.Interrupt
.Level
= Irq
[i
];
1388 PartialDescriptor
->u
.Interrupt
.Vector
= Irq
[i
];
1389 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1391 /* Set serial data (device specific) */
1392 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[2];
1393 PartialDescriptor
->Type
= CmResourceTypeDeviceSpecific
;
1394 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1395 PartialDescriptor
->Flags
= 0;
1396 PartialDescriptor
->u
.DeviceSpecificData
.DataSize
= sizeof(CM_SERIAL_DEVICE_DATA
);
1399 (PCM_SERIAL_DEVICE_DATA
)&FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[3];
1400 SerialDeviceData
->BaudClock
= 1843200; /* UART Clock frequency (Hertz) */
1402 /* Set 'Configuration Data' value */
1403 Error
= RegSetValue(ControllerKey
,
1404 L
"Configuration Data",
1405 REG_FULL_RESOURCE_DESCRIPTOR
,
1406 (PCHAR
) FullResourceDescriptor
,
1408 MmFreeMemory(FullResourceDescriptor
);
1409 if (Error
!= ERROR_SUCCESS
)
1411 DbgPrint((DPRINT_HWDETECT
,
1412 "RegSetValue(Configuration Data) failed (Error %u)\n",
1416 /* Set 'Identifier' value */
1420 Error
= RegSetValue(ControllerKey
,
1424 (wcslen(Buffer
) + 1) * sizeof(WCHAR
));
1425 if (Error
!= ERROR_SUCCESS
)
1427 DbgPrint((DPRINT_HWDETECT
,
1428 "RegSetValue() failed (Error %u)\n",
1432 DbgPrint((DPRINT_HWDETECT
,
1433 "Created value: Identifier %s\n",
1436 if (!Rs232PortInUse(Base
))
1438 /* Detect serial mouse */
1439 DetectSerialPointerPeripheral(ControllerKey
, Base
);
1448 DetectParallelPorts(FRLDRHKEY BusKey
)
1450 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1451 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1452 ULONG Irq
[3] = {7, 5, (ULONG
)-1};
1454 FRLDRHKEY ControllerKey
;
1457 ULONG ControllerNumber
;
1462 DbgPrint((DPRINT_HWDETECT
, "DetectParallelPorts() called\n"));
1464 ControllerNumber
= 0;
1465 BasePtr
= (PUSHORT
)0x408;
1466 for (i
= 0; i
< 3; i
++, BasePtr
++)
1468 Base
= (ULONG
)*BasePtr
;
1472 DbgPrint((DPRINT_HWDETECT
,
1473 "Parallel port %u: %x\n",
1477 /* Create controller key */
1479 L
"ParallelController\\%u",
1482 Error
= RegCreateKey(BusKey
,
1485 if (Error
!= ERROR_SUCCESS
)
1487 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1490 DbgPrint((DPRINT_HWDETECT
, "Created key: %S\n", Buffer
));
1492 /* Set 'ComponentInformation' value */
1493 SetComponentInformation(ControllerKey
,
1498 /* Build full device descriptor */
1499 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
);
1500 if (Irq
[i
] != (ULONG
)-1)
1501 Size
+= sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
1503 FullResourceDescriptor
= MmAllocateMemory(Size
);
1504 if (FullResourceDescriptor
== NULL
)
1506 DbgPrint((DPRINT_HWDETECT
,
1507 "Failed to allocate resource descriptor\n"));
1510 memset(FullResourceDescriptor
, 0, Size
);
1512 /* Initialize resource descriptor */
1513 FullResourceDescriptor
->InterfaceType
= Isa
;
1514 FullResourceDescriptor
->BusNumber
= 0;
1515 FullResourceDescriptor
->PartialResourceList
.Count
= (Irq
[i
] != (ULONG
)-1) ? 2 : 1;
1518 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1519 PartialDescriptor
->Type
= CmResourceTypePort
;
1520 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1521 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1522 PartialDescriptor
->u
.Port
.Start
.LowPart
= Base
;
1523 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1524 PartialDescriptor
->u
.Port
.Length
= 3;
1527 if (Irq
[i
] != (ULONG
)-1)
1529 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
1530 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
1531 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1532 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1533 PartialDescriptor
->u
.Interrupt
.Level
= Irq
[i
];
1534 PartialDescriptor
->u
.Interrupt
.Vector
= Irq
[i
];
1535 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1538 /* Set 'Configuration Data' value */
1539 Error
= RegSetValue(ControllerKey
,
1540 L
"Configuration Data",
1541 REG_FULL_RESOURCE_DESCRIPTOR
,
1542 (PCHAR
) FullResourceDescriptor
,
1544 MmFreeMemory(FullResourceDescriptor
);
1545 if (Error
!= ERROR_SUCCESS
)
1547 DbgPrint((DPRINT_HWDETECT
,
1548 "RegSetValue(Configuration Data) failed (Error %u)\n",
1552 /* Set 'Identifier' value */
1556 Error
= RegSetValue(ControllerKey
,
1560 (wcslen(Buffer
) + 1) * sizeof(WCHAR
));
1561 if (Error
!= ERROR_SUCCESS
)
1563 DbgPrint((DPRINT_HWDETECT
,
1564 "RegSetValue() failed (Error %u)\n",
1568 DbgPrint((DPRINT_HWDETECT
,
1569 "Created value: Identifier %s\n",
1575 DbgPrint((DPRINT_HWDETECT
, "DetectParallelPorts() done\n"));
1580 DetectKeyboardDevice(VOID
)
1585 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
,
1588 StallExecutionProcessor(10000);
1590 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1591 if ((Status
& 0x01) != 0x01)
1593 /* PC/XT keyboard or no keyboard */
1597 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1598 if (Scancode
!= 0xFA)
1600 /* No ACK received */
1604 StallExecutionProcessor(10000);
1605 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1606 if ((Status
& 0x01) != 0x01)
1608 /* Found AT keyboard */
1612 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1613 if (Scancode
!= 0xAB)
1615 /* No 0xAB received */
1619 StallExecutionProcessor(10000);
1620 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1621 if ((Status
& 0x01) != 0x01)
1623 /* No byte in buffer */
1627 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1628 if (Scancode
!= 0x41)
1630 /* No 0x41 received */
1634 /* Found MF-II keyboard */
1640 DetectKeyboardPeripheral(FRLDRHKEY ControllerKey
)
1642 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1643 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1644 PCM_KEYBOARD_DEVICE_DATA KeyboardData
;
1645 FRLDRHKEY PeripheralKey
;
1649 if (DetectKeyboardDevice())
1651 /* Create controller key */
1652 Error
= RegCreateKey(ControllerKey
,
1653 L
"KeyboardPeripheral\\0",
1655 if (Error
!= ERROR_SUCCESS
)
1657 DbgPrint((DPRINT_HWDETECT
, "Failed to create peripheral key\n"));
1660 DbgPrint((DPRINT_HWDETECT
, "Created key: KeyboardPeripheral\\0\n"));
1662 /* Set 'ComponentInformation' value */
1663 SetComponentInformation(ControllerKey
,
1668 /* Set 'Configuration Data' value */
1669 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
1670 sizeof(CM_KEYBOARD_DEVICE_DATA
);
1671 FullResourceDescriptor
= MmAllocateMemory(Size
);
1672 if (FullResourceDescriptor
== NULL
)
1674 DbgPrint((DPRINT_HWDETECT
,
1675 "Failed to allocate resource descriptor\n"));
1679 /* Initialize resource descriptor */
1680 memset(FullResourceDescriptor
, 0, Size
);
1681 FullResourceDescriptor
->InterfaceType
= Isa
;
1682 FullResourceDescriptor
->BusNumber
= 0;
1683 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
1685 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1686 PartialDescriptor
->Type
= CmResourceTypeDeviceSpecific
;
1687 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1688 PartialDescriptor
->u
.DeviceSpecificData
.DataSize
= sizeof(CM_KEYBOARD_DEVICE_DATA
);
1690 KeyboardData
= (PVOID
)(((ULONG_PTR
)FullResourceDescriptor
) + sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1691 KeyboardData
->Version
= 0;
1692 KeyboardData
->Revision
= 0;
1693 KeyboardData
->Type
= 4;
1694 KeyboardData
->Subtype
= 0;
1695 KeyboardData
->KeyboardFlags
= 0x20;
1697 /* Set 'Configuration Data' value */
1698 Error
= RegSetValue(PeripheralKey
,
1699 L
"Configuration Data",
1700 REG_FULL_RESOURCE_DESCRIPTOR
,
1701 (PCHAR
)FullResourceDescriptor
,
1703 MmFreeMemory(FullResourceDescriptor
);
1704 if (Error
!= ERROR_SUCCESS
)
1706 DbgPrint((DPRINT_HWDETECT
,
1707 "RegSetValue(Configuration Data) failed (Error %u)\n",
1711 /* Set 'Identifier' value */
1712 Error
= RegSetValue(PeripheralKey
,
1715 (PCHAR
)L
"PCAT_ENHANCED",
1716 14 * sizeof(WCHAR
));
1717 if (Error
!= ERROR_SUCCESS
)
1719 DbgPrint((DPRINT_HWDETECT
,
1720 "RegSetValue() failed (Error %u)\n",
1728 DetectKeyboardController(FRLDRHKEY BusKey
)
1730 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1731 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1732 FRLDRHKEY ControllerKey
;
1736 /* Create controller key */
1737 Error
= RegCreateKey(BusKey
,
1738 L
"KeyboardController\\0",
1740 if (Error
!= ERROR_SUCCESS
)
1742 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1745 DbgPrint((DPRINT_HWDETECT
, "Created key: KeyboardController\\0\n"));
1747 /* Set 'ComponentInformation' value */
1748 SetComponentInformation(ControllerKey
,
1753 /* Set 'Configuration Data' value */
1754 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
1755 2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
1756 FullResourceDescriptor
= MmAllocateMemory(Size
);
1757 if (FullResourceDescriptor
== NULL
)
1759 DbgPrint((DPRINT_HWDETECT
,
1760 "Failed to allocate resource descriptor\n"));
1764 /* Initialize resource descriptor */
1765 memset(FullResourceDescriptor
, 0, Size
);
1766 FullResourceDescriptor
->InterfaceType
= Isa
;
1767 FullResourceDescriptor
->BusNumber
= 0;
1768 FullResourceDescriptor
->PartialResourceList
.Count
= 3;
1771 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1772 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
1773 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1774 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1775 PartialDescriptor
->u
.Interrupt
.Level
= 1;
1776 PartialDescriptor
->u
.Interrupt
.Vector
= 1;
1777 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1779 /* Set IO Port 0x60 */
1780 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
1781 PartialDescriptor
->Type
= CmResourceTypePort
;
1782 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1783 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1784 PartialDescriptor
->u
.Port
.Start
.LowPart
= 0x60;
1785 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1786 PartialDescriptor
->u
.Port
.Length
= 1;
1788 /* Set IO Port 0x64 */
1789 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[2];
1790 PartialDescriptor
->Type
= CmResourceTypePort
;
1791 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1792 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1793 PartialDescriptor
->u
.Port
.Start
.LowPart
= 0x64;
1794 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1795 PartialDescriptor
->u
.Port
.Length
= 1;
1797 /* Set 'Configuration Data' value */
1798 Error
= RegSetValue(ControllerKey
,
1799 L
"Configuration Data",
1800 REG_FULL_RESOURCE_DESCRIPTOR
,
1801 (PCHAR
)FullResourceDescriptor
,
1803 MmFreeMemory(FullResourceDescriptor
);
1804 if (Error
!= ERROR_SUCCESS
)
1806 DbgPrint((DPRINT_HWDETECT
,
1807 "RegSetValue(Configuration Data) failed (Error %u)\n",
1812 DetectKeyboardPeripheral(ControllerKey
);
1817 PS2ControllerWait(VOID
)
1822 for (Timeout
= 0; Timeout
< CONTROLLER_TIMEOUT
; Timeout
++)
1824 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1825 if ((Status
& CONTROLLER_STATUS_INPUT_BUFFER_FULL
) == 0)
1828 /* Sleep for one millisecond */
1829 StallExecutionProcessor(1000);
1835 DetectPS2AuxPort(VOID
)
1841 /* Put the value 0x5A in the output buffer using the
1842 * "WriteAuxiliary Device Output Buffer" command (0xD3).
1843 * Poll the Status Register for a while to see if the value really turns up
1844 * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1845 * to 1 in the Status Register, we assume this controller has an
1846 * Auxiliary Port (a.k.a. Mouse Port).
1848 PS2ControllerWait();
1849 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_CONTROL
,
1850 CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER
);
1851 PS2ControllerWait();
1853 /* 0x5A is a random dummy value */
1854 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
,
1857 for (Loops
= 0; Loops
< 10; Loops
++)
1859 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1861 if ((Status
& CONTROLLER_STATUS_OUTPUT_BUFFER_FULL
) != 0)
1863 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1864 if ((Status
& CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
) != 0)
1871 StallExecutionProcessor(10000);
1879 DetectPS2AuxDevice(VOID
)
1884 PS2ControllerWait();
1885 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_CONTROL
,
1886 CONTROLLER_COMMAND_WRITE_MOUSE
);
1887 PS2ControllerWait();
1889 /* Identify device */
1890 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
,
1893 StallExecutionProcessor(10000);
1895 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1896 if ((Status
& CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
) == 0)
1901 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1902 if (Scancode
!= 0xFA)
1905 StallExecutionProcessor(10000);
1907 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1908 if ((Status
& CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
) == 0)
1913 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1914 if (Scancode
!= 0x00)
1922 DetectPS2Mouse(FRLDRHKEY BusKey
)
1924 CM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1925 FRLDRHKEY ControllerKey
;
1926 FRLDRHKEY PeripheralKey
;
1929 if (DetectPS2AuxPort())
1931 DbgPrint((DPRINT_HWDETECT
, "Detected PS2 port\n"));
1933 /* Create controller key */
1934 Error
= RegCreateKey(BusKey
,
1935 L
"PointerController\\0",
1937 if (Error
!= ERROR_SUCCESS
)
1939 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1942 DbgPrint((DPRINT_HWDETECT
, "Created key: PointerController\\0\n"));
1944 /* Set 'ComponentInformation' value */
1945 SetComponentInformation(ControllerKey
,
1950 memset(&FullResourceDescriptor
, 0, sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1952 /* Initialize resource descriptor */
1953 FullResourceDescriptor
.InterfaceType
= Isa
;
1954 FullResourceDescriptor
.BusNumber
= 0;
1955 FullResourceDescriptor
.PartialResourceList
.Count
= 1;
1958 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].Type
= CmResourceTypeInterrupt
;
1959 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].ShareDisposition
= CmResourceShareUndetermined
;
1960 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1961 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].u
.Interrupt
.Level
= 12;
1962 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].u
.Interrupt
.Vector
= 12;
1963 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1965 /* Set 'Configuration Data' value */
1966 Error
= RegSetValue(ControllerKey
,
1967 L
"Configuration Data",
1968 REG_FULL_RESOURCE_DESCRIPTOR
,
1969 (PCHAR
)&FullResourceDescriptor
,
1970 sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1971 if (Error
!= ERROR_SUCCESS
)
1973 DbgPrint((DPRINT_HWDETECT
,
1974 "RegSetValue(Configuration Data) failed (Error %u)\n",
1980 if (DetectPS2AuxDevice())
1982 DbgPrint((DPRINT_HWDETECT
, "Detected PS2 mouse\n"));
1984 /* Create peripheral key */
1985 Error
= RegCreateKey(ControllerKey
,
1986 L
"PointerPeripheral\\0",
1988 if (Error
!= ERROR_SUCCESS
)
1990 DbgPrint((DPRINT_HWDETECT
, "Failed to create peripheral key\n"));
1993 DbgPrint((DPRINT_HWDETECT
, "Created key: PointerPeripheral\\0\n"));
1995 /* Set 'ComponentInformation' value */
1996 SetComponentInformation(PeripheralKey
,
2001 /* Initialize resource descriptor */
2002 memset(&FullResourceDescriptor
, 0, sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
2003 FullResourceDescriptor
.InterfaceType
= Isa
;
2004 FullResourceDescriptor
.BusNumber
= 0;
2005 FullResourceDescriptor
.PartialResourceList
.Count
= 0;
2007 /* Set 'Configuration Data' value */
2008 Error
= RegSetValue(PeripheralKey
,
2009 L
"Configuration Data",
2010 REG_FULL_RESOURCE_DESCRIPTOR
,
2011 (PCHAR
)&FullResourceDescriptor
,
2012 sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) -
2013 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
));
2014 if (Error
!= ERROR_SUCCESS
)
2016 DbgPrint((DPRINT_HWDETECT
,
2017 "RegSetValue(Configuration Data) failed (Error %u)\n",
2022 /* Set 'Identifier' value */
2023 Error
= RegSetValue(PeripheralKey
,
2026 (PCHAR
)L
"MICROSOFT PS2 MOUSE",
2027 20 * sizeof(WCHAR
));
2028 if (Error
!= ERROR_SUCCESS
)
2030 DbgPrint((DPRINT_HWDETECT
,
2031 "RegSetValue() failed (Error %u)\n",
2041 DetectDisplayController(FRLDRHKEY BusKey
)
2044 FRLDRHKEY ControllerKey
;
2048 Error
= RegCreateKey(BusKey
,
2049 L
"DisplayController\\0",
2051 if (Error
!= ERROR_SUCCESS
)
2053 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
2056 DbgPrint((DPRINT_HWDETECT
, "Created key: PointerController\\0\n"));
2058 /* Set 'ComponentInformation' value */
2059 SetComponentInformation(ControllerKey
,
2064 /* FIXME: Set 'ComponentInformation' value */
2066 VesaVersion
= BiosIsVesaSupported();
2067 if (VesaVersion
!= 0)
2069 DbgPrint((DPRINT_HWDETECT
,
2070 "VESA version %c.%c\n",
2071 (VesaVersion
>> 8) + '0',
2072 (VesaVersion
& 0xFF) + '0'));
2076 DbgPrint((DPRINT_HWDETECT
,
2077 "VESA not supported\n"));
2080 if (VesaVersion
>= 0x0200)
2091 /* Set 'Identifier' value */
2092 Error
= RegSetValue(ControllerKey
,
2096 (wcslen(Buffer
) + 1) * sizeof(WCHAR
));
2097 if (Error
!= ERROR_SUCCESS
)
2099 DbgPrint((DPRINT_HWDETECT
,
2100 "RegSetValue() failed (Error %u)\n",
2105 /* FIXME: Add display peripheral (monitor) data */
2110 DetectIsaBios(FRLDRHKEY SystemKey
, ULONG
*BusNumber
)
2112 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
2118 /* Create new bus key */
2120 L
"MultifunctionAdapter\\%u", *BusNumber
);
2121 Error
= RegCreateKey(SystemKey
,
2124 if (Error
!= ERROR_SUCCESS
)
2126 DbgPrint((DPRINT_HWDETECT
, "RegCreateKey() failed (Error %u)\n", (int)Error
));
2130 /* Set 'Component Information' value similar to my NT4 box */
2131 SetComponentInformation(BusKey
,
2136 /* Increment bus number */
2139 /* Set 'Identifier' value */
2140 Error
= RegSetValue(BusKey
,
2145 if (Error
!= ERROR_SUCCESS
)
2147 DbgPrint((DPRINT_HWDETECT
, "RegSetValue() failed (Error %u)\n", (int)Error
));
2151 /* Set 'Configuration Data' value */
2152 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) -
2153 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
2154 FullResourceDescriptor
= MmAllocateMemory(Size
);
2155 if (FullResourceDescriptor
== NULL
)
2157 DbgPrint((DPRINT_HWDETECT
,
2158 "Failed to allocate resource descriptor\n"));
2162 /* Initialize resource descriptor */
2163 memset(FullResourceDescriptor
, 0, Size
);
2164 FullResourceDescriptor
->InterfaceType
= Isa
;
2165 FullResourceDescriptor
->BusNumber
= 0;
2166 FullResourceDescriptor
->PartialResourceList
.Count
= 0;
2168 /* Set 'Configuration Data' value */
2169 Error
= RegSetValue(BusKey
,
2170 L
"Configuration Data",
2171 REG_FULL_RESOURCE_DESCRIPTOR
,
2172 (PCHAR
) FullResourceDescriptor
,
2174 MmFreeMemory(FullResourceDescriptor
);
2175 if (Error
!= ERROR_SUCCESS
)
2177 DbgPrint((DPRINT_HWDETECT
,
2178 "RegSetValue(Configuration Data) failed (Error %u)\n",
2183 /* Detect ISA/BIOS devices */
2184 DetectBiosDisks(SystemKey
, BusKey
);
2186 DetectBiosFloppyController(SystemKey
, BusKey
);
2188 DetectSerialPorts(BusKey
);
2190 DetectParallelPorts(BusKey
);
2192 DetectKeyboardController(BusKey
);
2194 DetectPS2Mouse(BusKey
);
2196 DetectDisplayController(BusKey
);
2198 /* FIXME: Detect more ISA devices */
2205 FRLDRHKEY SystemKey
;
2206 ULONG BusNumber
= 0;
2209 DbgPrint((DPRINT_HWDETECT
, "DetectHardware()\n"));
2211 /* Create the 'System' key */
2212 Error
= RegCreateKey(NULL
,
2213 L
"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
2215 if (Error
!= ERROR_SUCCESS
)
2217 DbgPrint((DPRINT_HWDETECT
, "RegCreateKey() failed (Error %u)\n", (int)Error
));
2224 DetectCPUs(SystemKey
);
2227 DetectPciBios(SystemKey
, &BusNumber
);
2228 DetectApmBios(SystemKey
, &BusNumber
);
2229 DetectPnpBios(SystemKey
, &BusNumber
);
2230 DetectIsaBios(SystemKey
, &BusNumber
);
2231 DetectAcpiBios(SystemKey
, &BusNumber
);
2233 DbgPrint((DPRINT_HWDETECT
, "DetectHardware() Done\n"));
2236 printf("*** System stopped ***\n");