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.
31 #include "../../reactos/registry.h"
39 #define CLOCK_TICK_RATE (1193182)
40 #define LATCH (CLOCK_TICK_RATE / HZ)
44 #define MOUSE_TYPE_NONE 0
45 /* Microsoft Mouse with 2 buttons */
46 #define MOUSE_TYPE_MICROSOFT 1
47 /* Logitech Mouse with 3 buttons */
48 #define MOUSE_TYPE_LOGITECH 2
49 /* Microsoft Wheel Mouse (aka Z Mouse) */
50 #define MOUSE_TYPE_WHEELZ 3
51 /* Mouse Systems Mouse */
52 #define MOUSE_TYPE_MOUSESYSTEMS 4
57 /* Controller registers. */
58 #define CONTROLLER_REGISTER_STATUS 0x64
59 #define CONTROLLER_REGISTER_CONTROL 0x64
60 #define CONTROLLER_REGISTER_DATA 0x60
62 /* Controller commands. */
63 #define CONTROLLER_COMMAND_READ_MODE 0x20
64 #define CONTROLLER_COMMAND_WRITE_MODE 0x60
65 #define CONTROLLER_COMMAND_GET_VERSION 0xA1
66 #define CONTROLLER_COMMAND_MOUSE_DISABLE 0xA7
67 #define CONTROLLER_COMMAND_MOUSE_ENABLE 0xA8
68 #define CONTROLLER_COMMAND_TEST_MOUSE 0xA9
69 #define CONTROLLER_COMMAND_SELF_TEST 0xAA
70 #define CONTROLLER_COMMAND_KEYBOARD_TEST 0xAB
71 #define CONTROLLER_COMMAND_KEYBOARD_DISABLE 0xAD
72 #define CONTROLLER_COMMAND_KEYBOARD_ENABLE 0xAE
73 #define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER 0xD3
74 #define CONTROLLER_COMMAND_WRITE_MOUSE 0xD4
76 /* Controller status */
77 #define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL 0x01
78 #define CONTROLLER_STATUS_INPUT_BUFFER_FULL 0x02
79 #define CONTROLLER_STATUS_SELF_TEST 0x04
80 #define CONTROLLER_STATUS_COMMAND 0x08
81 #define CONTROLLER_STATUS_UNLOCKED 0x10
82 #define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL 0x20
83 #define CONTROLLER_STATUS_GENERAL_TIMEOUT 0x40
84 #define CONTROLLER_STATUS_PARITY_ERROR 0x80
85 #define AUX_STATUS_OUTPUT_BUFFER_FULL (CONTROLLER_STATUS_OUTPUT_BUFFER_FULL | \
86 CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL)
88 /* Timeout in ms for sending to keyboard controller. */
89 #define CONTROLLER_TIMEOUT 250
92 typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA
95 ULONG NumberOfCylinders
;
96 ULONG SectorsPerTrack
;
98 } CM_DISK_GEOMETRY_DEVICE_DATA
, *PCM_DISK_GEOMETRY_DEVICE_DATA
;
101 typedef struct _CM_PNP_BIOS_DEVICE_NODE
107 USHORT DeviceAttributes
;
108 } __attribute__((packed
)) CM_PNP_BIOS_DEVICE_NODE
, *PCM_PNP_BIOS_DEVICE_NODE
;
111 typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK
118 ULONG EventFlagAddress
;
119 USHORT RealModeEntryOffset
;
120 USHORT RealModeEntrySegment
;
121 USHORT ProtectedModeEntryOffset
;
122 ULONG ProtectedModeCodeBaseAddress
;
124 USHORT RealModeDataBaseAddress
;
125 ULONG ProtectedModeDataBaseAddress
;
126 } __attribute__((packed
)) CM_PNP_BIOS_INSTALLATION_CHECK
, *PCM_PNP_BIOS_INSTALLATION_CHECK
;
129 static char Hex
[] = "0123456789ABCDEF";
130 static unsigned int delay_count
= 1;
133 /* FUNCTIONS ****************************************************************/
137 __StallExecutionProcessor(ULONG Loops
)
139 register unsigned int i
;
140 for (i
= 0; i
< Loops
; i
++);
144 VOID
StallExecutionProcessor(ULONG Microseconds
)
146 ULONGLONG LoopCount
= ((ULONGLONG
)delay_count
* (ULONGLONG
)Microseconds
) / 1000ULL;
147 __StallExecutionProcessor((ULONG
)LoopCount
);
156 WRITE_PORT_UCHAR((PUCHAR
)0x43, 0x00);
157 Count
= READ_PORT_UCHAR((PUCHAR
)0x40);
158 Count
|= READ_PORT_UCHAR((PUCHAR
)0x40) << 8;
165 WaitFor8254Wraparound(VOID
)
168 ULONG PrevCount
= ~0;
171 CurCount
= Read8254Timer();
175 PrevCount
= CurCount
;
176 CurCount
= Read8254Timer();
177 Delta
= CurCount
- PrevCount
;
180 * This limit for delta seems arbitrary, but it isn't, it's
181 * slightly above the level of error a buggy Mercury/Neptune
182 * chipset timer can cause.
190 HalpCalibrateStallExecution(VOID
)
196 /* Initialise timer interrupt with MILLISECOND ms interval */
197 WRITE_PORT_UCHAR((PUCHAR
)0x43, 0x34); /* binary, mode 2, LSB/MSB, ch 0 */
198 WRITE_PORT_UCHAR((PUCHAR
)0x40, LATCH
& 0xff); /* LSB */
199 WRITE_PORT_UCHAR((PUCHAR
)0x40, LATCH
>> 8); /* MSB */
201 /* Stage 1: Coarse calibration */
203 WaitFor8254Wraparound();
208 delay_count
<<= 1; /* Next delay count to try */
210 WaitFor8254Wraparound();
212 __StallExecutionProcessor(delay_count
); /* Do the delay */
214 CurCount
= Read8254Timer();
215 } while (CurCount
> LATCH
/ 2);
217 delay_count
>>= 1; /* Get bottom value for delay */
219 /* Stage 2: Fine calibration */
221 calib_bit
= delay_count
; /* Which bit are we going to test */
223 for(i
=0;i
<PRECISION
;i
++) {
224 calib_bit
>>= 1; /* Next bit to calibrate */
225 if(!calib_bit
) break; /* If we have done all bits, stop */
227 delay_count
|= calib_bit
; /* Set the bit in delay_count */
229 WaitFor8254Wraparound();
231 __StallExecutionProcessor(delay_count
); /* Do the delay */
233 CurCount
= Read8254Timer();
234 if (CurCount
<= LATCH
/ 2) /* If a tick has passed, turn the */
235 delay_count
&= ~calib_bit
; /* calibrated bit back off */
238 /* We're finished: Do the finishing touches */
239 delay_count
/= (MILLISEC
/ 2); /* Calculate delay_count for 1ms */
244 SetComponentInformation(FRLDRHKEY ComponentKey
,
249 CM_COMPONENT_INFORMATION CompInfo
;
252 CompInfo
.Flags
= Flags
;
253 CompInfo
.Version
= 0;
255 CompInfo
.Affinity
= Affinity
;
257 /* Set 'Component Information' value */
258 Error
= RegSetValue(ComponentKey
,
259 "Component Information",
262 sizeof(CM_COMPONENT_INFORMATION
));
263 if (Error
!= ERROR_SUCCESS
)
265 DbgPrint((DPRINT_HWDETECT
, "RegSetValue() failed (Error %u)\n", (int)Error
));
271 DetectPnpBios(FRLDRHKEY SystemKey
, ULONG
*BusNumber
)
273 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
274 PCM_PNP_BIOS_DEVICE_NODE DeviceNode
;
275 PCM_PNP_BIOS_INSTALLATION_CHECK InstData
;
282 ULONG FoundNodeCount
;
289 InstData
= (PCM_PNP_BIOS_INSTALLATION_CHECK
)PnpBiosSupported();
290 if (InstData
== NULL
|| strncmp((CHAR
*)InstData
->Signature
, "$PnP", 4))
292 DbgPrint((DPRINT_HWDETECT
, "PnP-BIOS not supported\n"));
295 DbgPrint((DPRINT_HWDETECT
, "Signature '%c%c%c%c'\n",
296 InstData
->Signature
[0], InstData
->Signature
[1],
297 InstData
->Signature
[2], InstData
->Signature
[3]));
300 x
= PnpBiosGetDeviceNodeCount(&NodeSize
, &NodeCount
);
301 NodeCount
&= 0xFF; // needed since some fscked up BIOSes return
302 // wrong info (e.g. Mac Virtual PC)
303 // e.g. look: http://my.execpc.com/~geezer/osd/pnp/pnp16.c
304 if (x
!= 0 || NodeSize
== 0 || NodeCount
== 0)
306 DbgPrint((DPRINT_HWDETECT
, "PnP-BIOS failed to enumerate device nodes\n"));
309 DbgPrint((DPRINT_HWDETECT
, "PnP-BIOS supported\n"));
310 DbgPrint((DPRINT_HWDETECT
, "MaxNodeSize %u NodeCount %u\n", NodeSize
, NodeCount
));
311 DbgPrint((DPRINT_HWDETECT
, "Estimated buffer size %u\n", NodeSize
* NodeCount
));
313 /* Create new bus key */
315 "MultifunctionAdapter\\%u", *BusNumber
);
316 Error
= RegCreateKey(SystemKey
,
319 if (Error
!= ERROR_SUCCESS
)
321 DbgPrint((DPRINT_HWDETECT
, "RegCreateKey() failed (Error %u)\n", (int)Error
));
325 /* Increment bus number */
328 /* Set 'Component Information' value similar to my NT4 box */
329 SetComponentInformation(BusKey
,
334 /* Set 'Identifier' value */
335 Error
= RegSetValue(BusKey
,
340 if (Error
!= ERROR_SUCCESS
)
342 DbgPrint((DPRINT_HWDETECT
, "RegSetValue() failed (Error %u)\n", (int)Error
));
346 /* Set 'Configuration Data' value */
347 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) + (NodeSize
* NodeCount
);
348 FullResourceDescriptor
= MmAllocateMemory(Size
);
349 if (FullResourceDescriptor
== NULL
)
351 DbgPrint((DPRINT_HWDETECT
,
352 "Failed to allocate resource descriptor\n"));
355 memset(FullResourceDescriptor
, 0, Size
);
357 /* Initialize resource descriptor */
358 FullResourceDescriptor
->InterfaceType
= Internal
;
359 FullResourceDescriptor
->BusNumber
= 0;
360 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
361 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].Type
=
362 CmResourceTypeDeviceSpecific
;
363 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].ShareDisposition
=
364 CmResourceShareUndetermined
;
366 Ptr
= (char *)(((ULONG_PTR
)&FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0]) +
367 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
));
369 /* Set instalation check data */
370 memcpy (Ptr
, InstData
, sizeof(CM_PNP_BIOS_INSTALLATION_CHECK
));
371 Ptr
+= sizeof(CM_PNP_BIOS_INSTALLATION_CHECK
);
373 /* Copy device nodes */
375 PnpBufferSize
= sizeof(CM_PNP_BIOS_INSTALLATION_CHECK
);
376 for (i
= 0; i
< 0xFF; i
++)
378 NodeNumber
= (UCHAR
)i
;
380 x
= PnpBiosGetDeviceNode(&NodeNumber
, (PVOID
)DISKREADBUFFER
);
383 DeviceNode
= (PCM_PNP_BIOS_DEVICE_NODE
)DISKREADBUFFER
;
385 DbgPrint((DPRINT_HWDETECT
,
386 "Node: %u Size %u (0x%x)\n",
395 Ptr
+= DeviceNode
->Size
;
396 PnpBufferSize
+= DeviceNode
->Size
;
399 if (FoundNodeCount
>= NodeCount
)
404 /* Set real data size */
405 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].u
.DeviceSpecificData
.DataSize
=
407 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) + PnpBufferSize
;
409 DbgPrint((DPRINT_HWDETECT
, "Real buffer size: %u\n", PnpBufferSize
));
410 DbgPrint((DPRINT_HWDETECT
, "Resource size: %u\n", Size
));
412 /* Set 'Configuration Data' value */
413 Error
= RegSetValue(BusKey
,
414 "Configuration Data",
415 REG_FULL_RESOURCE_DESCRIPTOR
,
416 (PCHAR
) FullResourceDescriptor
,
418 MmFreeMemory(FullResourceDescriptor
);
419 if (Error
!= ERROR_SUCCESS
)
421 DbgPrint((DPRINT_HWDETECT
,
422 "RegSetValue(Configuration Data) failed (Error %u)\n",
430 SetHarddiskConfigurationData(FRLDRHKEY DiskKey
,
433 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
434 PCM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
;
435 EXTENDED_GEOMETRY ExtGeometry
;
440 /* Set 'Configuration Data' value */
441 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
442 sizeof(CM_DISK_GEOMETRY_DEVICE_DATA
);
443 FullResourceDescriptor
= MmAllocateMemory(Size
);
444 if (FullResourceDescriptor
== NULL
)
446 DbgPrint((DPRINT_HWDETECT
,
447 "Failed to allocate a full resource descriptor\n"));
451 memset(FullResourceDescriptor
, 0, Size
);
452 FullResourceDescriptor
->InterfaceType
= InterfaceTypeUndefined
;
453 FullResourceDescriptor
->BusNumber
= 0;
454 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
455 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].Type
=
456 CmResourceTypeDeviceSpecific
;
457 // FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].ShareDisposition =
458 // FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].Flags =
459 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].u
.DeviceSpecificData
.DataSize
=
460 sizeof(CM_DISK_GEOMETRY_DEVICE_DATA
);
462 /* Get pointer to geometry data */
463 DiskGeometry
= (PVOID
)(((ULONG_PTR
)FullResourceDescriptor
) + sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
465 /* Get the disk geometry */
466 ExtGeometry
.Size
= sizeof(EXTENDED_GEOMETRY
);
467 if (DiskGetExtendedDriveParameters(DriveNumber
, &ExtGeometry
, ExtGeometry
.Size
))
469 DiskGeometry
->BytesPerSector
= ExtGeometry
.BytesPerSector
;
470 DiskGeometry
->NumberOfCylinders
= ExtGeometry
.Cylinders
;
471 DiskGeometry
->SectorsPerTrack
= ExtGeometry
.SectorsPerTrack
;
472 DiskGeometry
->NumberOfHeads
= ExtGeometry
.Heads
;
474 else if(MachDiskGetDriveGeometry(DriveNumber
, &Geometry
))
476 DiskGeometry
->BytesPerSector
= Geometry
.BytesPerSector
;
477 DiskGeometry
->NumberOfCylinders
= Geometry
.Cylinders
;
478 DiskGeometry
->SectorsPerTrack
= Geometry
.Sectors
;
479 DiskGeometry
->NumberOfHeads
= Geometry
.Heads
;
483 DbgPrint((DPRINT_HWDETECT
, "Reading disk geometry failed\n"));
484 MmFreeMemory(FullResourceDescriptor
);
487 DbgPrint((DPRINT_HWDETECT
,
488 "Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
490 DiskGeometry
->NumberOfCylinders
,
491 DiskGeometry
->NumberOfHeads
,
492 DiskGeometry
->SectorsPerTrack
,
493 DiskGeometry
->BytesPerSector
));
495 Error
= RegSetValue(DiskKey
,
496 "Configuration Data",
497 REG_FULL_RESOURCE_DESCRIPTOR
,
498 (PCHAR
) FullResourceDescriptor
,
500 MmFreeMemory(FullResourceDescriptor
);
501 if (Error
!= ERROR_SUCCESS
)
503 DbgPrint((DPRINT_HWDETECT
,
504 "RegSetValue(Configuration Data) failed (Error %u)\n",
511 SetHarddiskIdentifier(FRLDRHKEY DiskKey
,
514 PMASTER_BOOT_RECORD Mbr
;
523 if (!MachDiskReadLogicalSectors(DriveNumber
, 0ULL, 1, (PVOID
)DISKREADBUFFER
))
525 DbgPrint((DPRINT_HWDETECT
, "Reading MBR failed\n"));
529 Buffer
= (ULONG
*)DISKREADBUFFER
;
530 Mbr
= (PMASTER_BOOT_RECORD
)DISKREADBUFFER
;
532 Signature
= Mbr
->Signature
;
533 DbgPrint((DPRINT_HWDETECT
, "Signature: %x\n", Signature
));
535 /* Calculate the MBR checksum */
537 for (i
= 0; i
< 128; i
++)
539 Checksum
+= Buffer
[i
];
541 Checksum
= ~Checksum
+ 1;
542 DbgPrint((DPRINT_HWDETECT
, "Checksum: %x\n", Checksum
));
544 /* Convert checksum and signature to identifier string */
545 Identifier
[0] = Hex
[(Checksum
>> 28) & 0x0F];
546 Identifier
[1] = Hex
[(Checksum
>> 24) & 0x0F];
547 Identifier
[2] = Hex
[(Checksum
>> 20) & 0x0F];
548 Identifier
[3] = Hex
[(Checksum
>> 16) & 0x0F];
549 Identifier
[4] = Hex
[(Checksum
>> 12) & 0x0F];
550 Identifier
[5] = Hex
[(Checksum
>> 8) & 0x0F];
551 Identifier
[6] = Hex
[(Checksum
>> 4) & 0x0F];
552 Identifier
[7] = Hex
[Checksum
& 0x0F];
554 Identifier
[9] = Hex
[(Signature
>> 28) & 0x0F];
555 Identifier
[10] = Hex
[(Signature
>> 24) & 0x0F];
556 Identifier
[11] = Hex
[(Signature
>> 20) & 0x0F];
557 Identifier
[12] = Hex
[(Signature
>> 16) & 0x0F];
558 Identifier
[13] = Hex
[(Signature
>> 12) & 0x0F];
559 Identifier
[14] = Hex
[(Signature
>> 8) & 0x0F];
560 Identifier
[15] = Hex
[(Signature
>> 4) & 0x0F];
561 Identifier
[16] = Hex
[Signature
& 0x0F];
562 Identifier
[17] = '-';
563 Identifier
[18] = 'A';
565 DbgPrint((DPRINT_HWDETECT
, "Identifier: %x\n", Identifier
));
568 Error
= RegSetValue(DiskKey
,
573 if (Error
!= ERROR_SUCCESS
)
575 DbgPrint((DPRINT_HWDETECT
,
576 "RegSetValue(Identifier) failed (Error %u)\n",
583 DetectBiosDisks(FRLDRHKEY SystemKey
,
586 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
587 PCM_INT13_DRIVE_PARAMETER Int13Drives
;
597 /* Count the number of visible drives */
598 DiskReportError(FALSE
);
601 /* There are some really broken BIOSes out there. There are even BIOSes
602 * that happily report success when you ask them to read from non-existent
603 * harddisks. So, we set the buffer to known contents first, then try to
604 * read. If the BIOS reports success but the buffer contents haven't
605 * changed then we fail anyway */
606 memset((PVOID
) DISKREADBUFFER
, 0xcd, 512);
607 while (MachDiskReadLogicalSectors(0x80 + DiskCount
, 0ULL, 1, (PVOID
)DISKREADBUFFER
))
610 for (i
= 0; ! Changed
&& i
< 512; i
++)
612 Changed
= ((PUCHAR
)DISKREADBUFFER
)[i
] != 0xcd;
616 DbgPrint((DPRINT_HWDETECT
, "BIOS reports success for disk %d but data didn't change\n",
621 memset((PVOID
) DISKREADBUFFER
, 0xcd, 512);
623 DiskReportError(TRUE
);
624 DbgPrint((DPRINT_HWDETECT
, "BIOS reports %d harddisk%s\n",
625 (int)DiskCount
, (DiskCount
== 1) ? "": "s"));
627 /* Allocate resource descriptor */
628 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
629 sizeof(CM_INT13_DRIVE_PARAMETER
) * DiskCount
;
630 FullResourceDescriptor
= MmAllocateMemory(Size
);
631 if (FullResourceDescriptor
== NULL
)
633 DbgPrint((DPRINT_HWDETECT
,
634 "Failed to allocate resource descriptor\n"));
638 /* Initialize resource descriptor */
639 memset(FullResourceDescriptor
, 0, Size
);
640 FullResourceDescriptor
->InterfaceType
= InterfaceTypeUndefined
;
641 FullResourceDescriptor
->BusNumber
= -1;
642 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
643 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].Type
=
644 CmResourceTypeDeviceSpecific
;
645 // FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].ShareDisposition =
646 // FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].Flags =
647 FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0].u
.DeviceSpecificData
.DataSize
=
648 sizeof(CM_INT13_DRIVE_PARAMETER
) * DiskCount
;
650 /* Get harddisk Int13 geometry data */
651 Int13Drives
= (PVOID
)(((ULONG_PTR
)FullResourceDescriptor
) + sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
652 for (i
= 0; i
< DiskCount
; i
++)
654 if (MachDiskGetDriveGeometry(0x80 + i
, &Geometry
))
656 Int13Drives
[i
].DriveSelect
= 0x80 + i
;
657 Int13Drives
[i
].MaxCylinders
= Geometry
.Cylinders
- 1;
658 Int13Drives
[i
].SectorsPerTrack
= Geometry
.Sectors
;
659 Int13Drives
[i
].MaxHeads
= Geometry
.Heads
- 1;
660 Int13Drives
[i
].NumberDrives
= DiskCount
;
662 DbgPrint((DPRINT_HWDETECT
,
663 "Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
665 Geometry
.Cylinders
- 1,
668 Geometry
.BytesPerSector
));
672 /* Set 'Configuration Data' value */
673 Error
= RegSetValue(SystemKey
,
674 "Configuration Data",
675 REG_FULL_RESOURCE_DESCRIPTOR
,
676 (PCHAR
) FullResourceDescriptor
,
678 MmFreeMemory(FullResourceDescriptor
);
679 if (Error
!= ERROR_SUCCESS
)
681 DbgPrint((DPRINT_HWDETECT
,
682 "RegSetValue(Configuration Data) failed (Error %u)\n",
687 /* Create and fill subkey for each harddisk */
688 for (i
= 0; i
< DiskCount
; i
++)
690 /* Create disk key */
692 "DiskController\\0\\DiskPeripheral\\%u",
695 Error
= RegCreateKey(BusKey
,
698 if (Error
!= ERROR_SUCCESS
)
700 DbgPrint((DPRINT_HWDETECT
, "Failed to create drive key\n"));
703 DbgPrint((DPRINT_HWDETECT
, "Created key: %s\n", Buffer
));
705 /* Set disk values */
706 SetHarddiskConfigurationData(DiskKey
, 0x80 + i
);
707 SetHarddiskIdentifier(DiskKey
, 0x80 + i
);
717 WRITE_PORT_UCHAR((PUCHAR
)0x70, 0x10);
718 Data
= READ_PORT_UCHAR((PUCHAR
)0x71);
720 return ((Data
& 0xF0) ? 1 : 0) + ((Data
& 0x0F) ? 1 : 0);
725 GetFloppyType(UCHAR DriveNumber
)
729 WRITE_PORT_UCHAR((PUCHAR
)0x70, 0x10);
730 Data
= READ_PORT_UCHAR((PUCHAR
)0x71);
732 if (DriveNumber
== 0)
734 else if (DriveNumber
== 1)
744 PUSHORT SegPtr
= (PUSHORT
)0x7A;
745 PUSHORT OfsPtr
= (PUSHORT
)0x78;
747 return (PVOID
)((ULONG_PTR
)(((ULONG
)(*SegPtr
)) << 4) + (ULONG
)(*OfsPtr
));
752 DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey
)
754 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
755 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
756 PCM_FLOPPY_DEVICE_DATA FloppyData
;
759 FRLDRHKEY PeripheralKey
;
764 ULONG MaxDensity
[6] = {0, 360, 1200, 720, 1440, 2880};
767 for (FloppyNumber
= 0; FloppyNumber
< 2; FloppyNumber
++)
769 FloppyType
= GetFloppyType(FloppyNumber
);
771 if ((FloppyType
> 5) || (FloppyType
== 0))
774 DiskResetController(FloppyNumber
);
776 Ptr
= GetInt1eTable();
778 sprintf(KeyName
, "FloppyDiskPeripheral\\%u", FloppyNumber
);
780 Error
= RegCreateKey(ControllerKey
,
781 "FloppyDiskPeripheral\\0",
783 if (Error
!= ERROR_SUCCESS
)
785 DbgPrint((DPRINT_HWDETECT
, "Failed to create peripheral key\n"));
789 DbgPrint((DPRINT_HWDETECT
, "Created key: %s\n", KeyName
));
791 /* Set 'ComponentInformation' value */
792 SetComponentInformation(PeripheralKey
,
797 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
798 sizeof(CM_FLOPPY_DEVICE_DATA
);
799 FullResourceDescriptor
= MmAllocateMemory(Size
);
800 if (FullResourceDescriptor
== NULL
)
802 DbgPrint((DPRINT_HWDETECT
,
803 "Failed to allocate resource descriptor\n"));
807 memset(FullResourceDescriptor
, 0, Size
);
808 FullResourceDescriptor
->InterfaceType
= Isa
;
809 FullResourceDescriptor
->BusNumber
= 0;
810 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
812 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
813 PartialDescriptor
->Type
= CmResourceTypeDeviceSpecific
;
814 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
815 PartialDescriptor
->u
.DeviceSpecificData
.DataSize
= sizeof(CM_FLOPPY_DEVICE_DATA
);
817 FloppyData
= (PVOID
)(((ULONG_PTR
)FullResourceDescriptor
) + sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
818 FloppyData
->Version
= 2;
819 FloppyData
->Revision
= 0;
820 FloppyData
->MaxDensity
= MaxDensity
[FloppyType
];
821 FloppyData
->MountDensity
= 0;
822 RtlCopyMemory(&FloppyData
->StepRateHeadUnloadTime
,
825 FloppyData
->MaximumTrackValue
= (FloppyType
== 1) ? 39 : 79;
826 FloppyData
->DataTransferRate
= 0;
828 /* Set 'Configuration Data' value */
829 Error
= RegSetValue(PeripheralKey
,
830 "Configuration Data",
831 REG_FULL_RESOURCE_DESCRIPTOR
,
832 (PCHAR
) FullResourceDescriptor
,
834 MmFreeMemory(FullResourceDescriptor
);
835 if (Error
!= ERROR_SUCCESS
)
837 DbgPrint((DPRINT_HWDETECT
,
838 "RegSetValue(Configuration Data) failed (Error %u)\n",
843 /* Set 'Identifier' value */
844 sprintf(Identifier
, "FLOPPY%u", FloppyNumber
+ 1);
845 Error
= RegSetValue(PeripheralKey
,
849 strlen(Identifier
) + 1);
850 if (Error
!= ERROR_SUCCESS
)
852 DbgPrint((DPRINT_HWDETECT
,
853 "RegSetValue() failed (Error %u)\n",
861 DetectBiosFloppyController(FRLDRHKEY SystemKey
,
864 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
865 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
866 FRLDRHKEY ControllerKey
;
871 FloppyCount
= GetFloppyCount();
872 DbgPrint((DPRINT_HWDETECT
,
873 "Floppy count: %u\n",
876 if (FloppyCount
== 0)
879 Error
= RegCreateKey(BusKey
,
882 if (Error
!= ERROR_SUCCESS
)
884 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
888 DbgPrint((DPRINT_HWDETECT
, "Created key: DiskController\\0\n"));
890 /* Set 'ComponentInformation' value */
891 SetComponentInformation(ControllerKey
,
896 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
897 2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
898 FullResourceDescriptor
= MmAllocateMemory(Size
);
899 if (FullResourceDescriptor
== NULL
)
901 DbgPrint((DPRINT_HWDETECT
,
902 "Failed to allocate resource descriptor\n"));
905 memset(FullResourceDescriptor
, 0, Size
);
907 /* Initialize resource descriptor */
908 FullResourceDescriptor
->InterfaceType
= Isa
;
909 FullResourceDescriptor
->BusNumber
= 0;
910 FullResourceDescriptor
->PartialResourceList
.Count
= 3;
913 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
914 PartialDescriptor
->Type
= CmResourceTypePort
;
915 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
916 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
917 PartialDescriptor
->u
.Port
.Start
.LowPart
= 0x03F0;
918 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
919 PartialDescriptor
->u
.Port
.Length
= 8;
922 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
923 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
924 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
925 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
926 PartialDescriptor
->u
.Interrupt
.Level
= 6;
927 PartialDescriptor
->u
.Interrupt
.Vector
= 6;
928 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
930 /* Set DMA channel */
931 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[2];
932 PartialDescriptor
->Type
= CmResourceTypeDma
;
933 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
934 PartialDescriptor
->Flags
= 0;
935 PartialDescriptor
->u
.Dma
.Channel
= 2;
936 PartialDescriptor
->u
.Dma
.Port
= 0;
938 /* Set 'Configuration Data' value */
939 Error
= RegSetValue(ControllerKey
,
940 "Configuration Data",
941 REG_FULL_RESOURCE_DESCRIPTOR
,
942 (PCHAR
) FullResourceDescriptor
,
944 MmFreeMemory(FullResourceDescriptor
);
945 if (Error
!= ERROR_SUCCESS
)
947 DbgPrint((DPRINT_HWDETECT
,
948 "RegSetValue(Configuration Data) failed (Error %u)\n",
953 DetectBiosFloppyPeripheral(ControllerKey
);
958 InitializeSerialPort(ULONG Port
,
961 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 3, 0x80); /* set DLAB on */
962 WRITE_PORT_UCHAR((PUCHAR
)Port
, 0x60); /* speed LO byte */
963 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 1, 0); /* speed HI byte */
964 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 3, LineControl
);
965 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 1, 0); /* set comm and DLAB to 0 */
966 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 4, 0x09); /* DR int enable */
967 READ_PORT_UCHAR((PUCHAR
)Port
+ 5); /* clear error bits */
972 DetectSerialMouse(ULONG Port
)
979 /* Shutdown mouse or something like that */
980 LineControl
= READ_PORT_UCHAR((PUCHAR
)Port
+ 4);
981 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 4, (LineControl
& ~0x02) | 0x01);
982 StallExecutionProcessor(100000);
985 while (READ_PORT_UCHAR((PUCHAR
)Port
+ 5) & 0x01)
986 READ_PORT_UCHAR((PUCHAR
)Port
);
989 * Send modem control with 'Data Terminal Ready', 'Request To Send' and
990 * 'Output Line 2' message. This enables mouse to identify.
992 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 4, 0x0b);
994 /* Wait 10 milliseconds for the mouse getting ready */
995 StallExecutionProcessor(10000);
997 /* Read first four bytes, which contains Microsoft Mouse signs */
998 for (i
= 0; i
< 4; i
++)
1000 while (((READ_PORT_UCHAR((PUCHAR
)Port
+ 5) & 1) == 0) && (TimeOut
> 0))
1002 StallExecutionProcessor(1000);
1005 return MOUSE_TYPE_NONE
;
1007 Buffer
[i
] = READ_PORT_UCHAR((PUCHAR
)Port
);
1010 DbgPrint((DPRINT_HWDETECT
,
1011 "Mouse data: %x %x %x %x\n",
1012 Buffer
[0],Buffer
[1],Buffer
[2],Buffer
[3]));
1014 /* Check that four bytes for signs */
1015 for (i
= 0; i
< 4; ++i
)
1017 if (Buffer
[i
] == 'B')
1019 /* Sign for Microsoft Ballpoint */
1020 // DbgPrint("Microsoft Ballpoint device detected\n");
1021 // DbgPrint("THIS DEVICE IS NOT SUPPORTED, YET\n");
1022 return MOUSE_TYPE_NONE
;
1024 else if (Buffer
[i
] == 'M')
1026 /* Sign for Microsoft Mouse protocol followed by button specifier */
1029 /* Overflow Error */
1030 return MOUSE_TYPE_NONE
;
1033 switch (Buffer
[i
+ 1])
1036 DbgPrint((DPRINT_HWDETECT
,
1037 "Microsoft Mouse with 3-buttons detected\n"));
1038 return MOUSE_TYPE_LOGITECH
;
1041 DbgPrint((DPRINT_HWDETECT
,
1042 "Microsoft Wheel Mouse detected\n"));
1043 return MOUSE_TYPE_WHEELZ
;
1047 DbgPrint((DPRINT_HWDETECT
,
1048 "Microsoft Mouse with 2-buttons detected\n"));
1049 return MOUSE_TYPE_MICROSOFT
;
1054 return MOUSE_TYPE_NONE
;
1059 GetSerialMousePnpId(ULONG Port
, char *Buffer
)
1066 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 4, 0x09);
1068 /* Wait 10 milliseconds for the mouse getting ready */
1069 StallExecutionProcessor(10000);
1071 WRITE_PORT_UCHAR((PUCHAR
)Port
+ 4, 0x0b);
1073 StallExecutionProcessor(10000);
1078 while (((READ_PORT_UCHAR((PUCHAR
)Port
+ 5) & 1) == 0) && (TimeOut
> 0))
1080 StallExecutionProcessor(1000);
1088 c
= READ_PORT_UCHAR((PUCHAR
)Port
);
1089 if (c
== 0x08 || c
== 0x28)
1099 while (((READ_PORT_UCHAR((PUCHAR
)Port
+ 5) & 1) == 0) && (TimeOut
> 0))
1101 StallExecutionProcessor(1000);
1106 c
= READ_PORT_UCHAR((PUCHAR
)Port
);
1119 DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey
,
1122 CM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1124 char Identifier
[256];
1125 FRLDRHKEY PeripheralKey
;
1132 DbgPrint((DPRINT_HWDETECT
,
1133 "DetectSerialPointerPeripheral()\n"));
1137 InitializeSerialPort(Base
, 2);
1138 MouseType
= DetectSerialMouse(Base
);
1140 if (MouseType
!= MOUSE_TYPE_NONE
)
1142 Length
= GetSerialMousePnpId(Base
, Buffer
);
1143 DbgPrint((DPRINT_HWDETECT
,
1144 "PnP ID length: %u\n",
1149 /* Convert PnP sting to ASCII */
1150 if (Buffer
[0] == 0x08)
1152 for (i
= 0; i
< Length
; i
++)
1157 DbgPrint((DPRINT_HWDETECT
,
1158 "PnP ID string: %s\n",
1161 /* Copy PnpId string */
1162 memcpy(&Identifier
[0],
1165 memcpy(&Identifier
[7],
1169 /* Skip device serial number */
1171 if (Buffer
[i
] == '\\')
1173 for (j
= ++i
; i
< Length
; ++i
)
1175 if (Buffer
[i
] == '\\')
1182 /* Skip PnP class */
1183 if (Buffer
[i
] == '\\')
1185 for (j
= ++i
; i
< Length
; ++i
)
1187 if (Buffer
[i
] == '\\')
1195 /* Skip compatible PnP Id */
1196 if (Buffer
[i
] == '\\')
1198 for (j
= ++i
; i
< Length
; ++i
)
1200 if (Buffer
[i
] == '\\')
1203 if (Buffer
[j
] == '*')
1209 /* Get product description */
1210 if (Buffer
[i
] == '\\')
1212 for (j
= ++i
; i
< Length
; ++i
)
1214 if (Buffer
[i
] == ';')
1221 memcpy(&Identifier
[10],
1224 Identifier
[10 + (i
-j
)] = 0;
1228 DbgPrint((DPRINT_HWDETECT
,
1229 "Identifier string: %s\n",
1233 if (Length
== 0 || strlen(Identifier
) < 11)
1237 case MOUSE_TYPE_LOGITECH
:
1239 "LOGITECH SERIAL MOUSE");
1242 case MOUSE_TYPE_WHEELZ
:
1244 "MICROSOFT SERIAL MOUSE WITH WHEEL");
1247 case MOUSE_TYPE_MICROSOFT
:
1250 "MICROSOFT SERIAL MOUSE");
1255 /* Create 'PointerPeripheral' key */
1256 Error
= RegCreateKey(ControllerKey
,
1257 "PointerPeripheral\\0",
1259 if (Error
!= ERROR_SUCCESS
)
1261 DbgPrint((DPRINT_HWDETECT
,
1262 "Failed to create peripheral key\n"));
1265 DbgPrint((DPRINT_HWDETECT
,
1266 "Created key: PointerPeripheral\\0\n"));
1268 /* Set 'ComponentInformation' value */
1269 SetComponentInformation(PeripheralKey
,
1274 /* Set 'Configuration Data' value */
1275 memset(&FullResourceDescriptor
, 0, sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1276 FullResourceDescriptor
.InterfaceType
= Isa
;
1277 FullResourceDescriptor
.BusNumber
= 0;
1278 FullResourceDescriptor
.PartialResourceList
.Count
= 0;
1280 Error
= RegSetValue(PeripheralKey
,
1281 "Configuration Data",
1282 REG_FULL_RESOURCE_DESCRIPTOR
,
1283 (PCHAR
)&FullResourceDescriptor
,
1284 sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) -
1285 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
));
1286 if (Error
!= ERROR_SUCCESS
)
1288 DbgPrint((DPRINT_HWDETECT
,
1289 "RegSetValue(Configuration Data) failed (Error %u)\n",
1293 /* Set 'Identifier' value */
1294 Error
= RegSetValue(PeripheralKey
,
1298 strlen(Identifier
) + 1);
1299 if (Error
!= ERROR_SUCCESS
)
1301 DbgPrint((DPRINT_HWDETECT
,
1302 "RegSetValue() failed (Error %u)\n",
1310 DetectSerialPorts(FRLDRHKEY BusKey
)
1312 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1313 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1314 PCM_SERIAL_DEVICE_DATA SerialDeviceData
;
1315 ULONG Irq
[4] = {4, 3, 4, 3};
1319 ULONG ControllerNumber
= 0;
1320 FRLDRHKEY ControllerKey
;
1325 DbgPrint((DPRINT_HWDETECT
, "DetectSerialPorts()\n"));
1327 ControllerNumber
= 0;
1328 BasePtr
= (PUSHORT
)0x400;
1329 for (i
= 0; i
< 4; i
++, BasePtr
++)
1331 Base
= (ULONG
)*BasePtr
;
1335 DbgPrint((DPRINT_HWDETECT
,
1336 "Found COM%u port at 0x%x\n",
1340 /* Create controller key */
1342 "SerialController\\%u",
1345 Error
= RegCreateKey(BusKey
,
1348 if (Error
!= ERROR_SUCCESS
)
1350 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1353 DbgPrint((DPRINT_HWDETECT
, "Created key: %s\n", Buffer
));
1355 /* Set 'ComponentInformation' value */
1356 SetComponentInformation(ControllerKey
,
1361 /* Build full device descriptor */
1362 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
1363 2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
) +
1364 sizeof(CM_SERIAL_DEVICE_DATA
);
1365 FullResourceDescriptor
= MmAllocateMemory(Size
);
1366 if (FullResourceDescriptor
== NULL
)
1368 DbgPrint((DPRINT_HWDETECT
,
1369 "Failed to allocate resource descriptor\n"));
1372 memset(FullResourceDescriptor
, 0, Size
);
1374 /* Initialize resource descriptor */
1375 FullResourceDescriptor
->InterfaceType
= Isa
;
1376 FullResourceDescriptor
->BusNumber
= 0;
1377 FullResourceDescriptor
->PartialResourceList
.Count
= 3;
1380 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1381 PartialDescriptor
->Type
= CmResourceTypePort
;
1382 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1383 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1384 PartialDescriptor
->u
.Port
.Start
.LowPart
= Base
;
1385 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1386 PartialDescriptor
->u
.Port
.Length
= 7;
1389 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
1390 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
1391 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1392 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1393 PartialDescriptor
->u
.Interrupt
.Level
= Irq
[i
];
1394 PartialDescriptor
->u
.Interrupt
.Vector
= Irq
[i
];
1395 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1397 /* Set serial data (device specific) */
1398 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[2];
1399 PartialDescriptor
->Type
= CmResourceTypeDeviceSpecific
;
1400 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1401 PartialDescriptor
->Flags
= 0;
1402 PartialDescriptor
->u
.DeviceSpecificData
.DataSize
= sizeof(CM_SERIAL_DEVICE_DATA
);
1405 (PCM_SERIAL_DEVICE_DATA
)&FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[3];
1406 SerialDeviceData
->BaudClock
= 1843200; /* UART Clock frequency (Hertz) */
1408 /* Set 'Configuration Data' value */
1409 Error
= RegSetValue(ControllerKey
,
1410 "Configuration Data",
1411 REG_FULL_RESOURCE_DESCRIPTOR
,
1412 (PCHAR
) FullResourceDescriptor
,
1414 MmFreeMemory(FullResourceDescriptor
);
1415 if (Error
!= ERROR_SUCCESS
)
1417 DbgPrint((DPRINT_HWDETECT
,
1418 "RegSetValue(Configuration Data) failed (Error %u)\n",
1422 /* Set 'Identifier' value */
1426 Error
= RegSetValue(ControllerKey
,
1430 strlen(Buffer
) + 1);
1431 if (Error
!= ERROR_SUCCESS
)
1433 DbgPrint((DPRINT_HWDETECT
,
1434 "RegSetValue() failed (Error %u)\n",
1438 DbgPrint((DPRINT_HWDETECT
,
1439 "Created value: Identifier %s\n",
1442 /* Detect serial mouse */
1443 DetectSerialPointerPeripheral(ControllerKey
, Base
);
1451 DetectParallelPorts(FRLDRHKEY BusKey
)
1453 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1454 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1455 ULONG Irq
[3] = {7, 5, (ULONG
)-1};
1457 FRLDRHKEY ControllerKey
;
1460 ULONG ControllerNumber
;
1465 DbgPrint((DPRINT_HWDETECT
, "DetectParallelPorts() called\n"));
1467 ControllerNumber
= 0;
1468 BasePtr
= (PUSHORT
)0x408;
1469 for (i
= 0; i
< 3; i
++, BasePtr
++)
1471 Base
= (ULONG
)*BasePtr
;
1475 DbgPrint((DPRINT_HWDETECT
,
1476 "Parallel port %u: %x\n",
1480 /* Create controller key */
1482 "ParallelController\\%u",
1485 Error
= RegCreateKey(BusKey
,
1488 if (Error
!= ERROR_SUCCESS
)
1490 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1493 DbgPrint((DPRINT_HWDETECT
, "Created key: %s\n", Buffer
));
1495 /* Set 'ComponentInformation' value */
1496 SetComponentInformation(ControllerKey
,
1501 /* Build full device descriptor */
1502 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
);
1503 if (Irq
[i
] != (ULONG
)-1)
1504 Size
+= sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
1506 FullResourceDescriptor
= MmAllocateMemory(Size
);
1507 if (FullResourceDescriptor
== NULL
)
1509 DbgPrint((DPRINT_HWDETECT
,
1510 "Failed to allocate resource descriptor\n"));
1513 memset(FullResourceDescriptor
, 0, Size
);
1515 /* Initialize resource descriptor */
1516 FullResourceDescriptor
->InterfaceType
= Isa
;
1517 FullResourceDescriptor
->BusNumber
= 0;
1518 FullResourceDescriptor
->PartialResourceList
.Count
= (Irq
[i
] != (ULONG
)-1) ? 2 : 1;
1521 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1522 PartialDescriptor
->Type
= CmResourceTypePort
;
1523 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1524 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1525 PartialDescriptor
->u
.Port
.Start
.LowPart
= Base
;
1526 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1527 PartialDescriptor
->u
.Port
.Length
= 3;
1530 if (Irq
[i
] != (ULONG
)-1)
1532 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
1533 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
1534 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1535 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1536 PartialDescriptor
->u
.Interrupt
.Level
= Irq
[i
];
1537 PartialDescriptor
->u
.Interrupt
.Vector
= Irq
[i
];
1538 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1541 /* Set 'Configuration Data' value */
1542 Error
= RegSetValue(ControllerKey
,
1543 "Configuration Data",
1544 REG_FULL_RESOURCE_DESCRIPTOR
,
1545 (PCHAR
) FullResourceDescriptor
,
1547 MmFreeMemory(FullResourceDescriptor
);
1548 if (Error
!= ERROR_SUCCESS
)
1550 DbgPrint((DPRINT_HWDETECT
,
1551 "RegSetValue(Configuration Data) failed (Error %u)\n",
1555 /* Set 'Identifier' value */
1559 Error
= RegSetValue(ControllerKey
,
1563 strlen(Buffer
) + 1);
1564 if (Error
!= ERROR_SUCCESS
)
1566 DbgPrint((DPRINT_HWDETECT
,
1567 "RegSetValue() failed (Error %u)\n",
1571 DbgPrint((DPRINT_HWDETECT
,
1572 "Created value: Identifier %s\n",
1578 DbgPrint((DPRINT_HWDETECT
, "DetectParallelPorts() done\n"));
1583 DetectKeyboardDevice(VOID
)
1588 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
,
1591 StallExecutionProcessor(10000);
1593 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1594 if ((Status
& 0x01) != 0x01)
1596 /* PC/XT keyboard or no keyboard */
1600 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1601 if (Scancode
!= 0xFA)
1603 /* No ACK received */
1607 StallExecutionProcessor(10000);
1608 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1609 if ((Status
& 0x01) != 0x01)
1611 /* Found AT keyboard */
1615 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1616 if (Scancode
!= 0xAB)
1618 /* No 0xAB received */
1622 StallExecutionProcessor(10000);
1623 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1624 if ((Status
& 0x01) != 0x01)
1626 /* No byte in buffer */
1630 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1631 if (Scancode
!= 0x41)
1633 /* No 0x41 received */
1637 /* Found MF-II keyboard */
1643 DetectKeyboardPeripheral(FRLDRHKEY ControllerKey
)
1645 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1646 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1647 PCM_KEYBOARD_DEVICE_DATA KeyboardData
;
1648 FRLDRHKEY PeripheralKey
;
1653 if (DetectKeyboardDevice())
1655 /* Create controller key */
1656 Error
= RegCreateKey(ControllerKey
,
1657 "KeyboardPeripheral\\0",
1659 if (Error
!= ERROR_SUCCESS
)
1661 DbgPrint((DPRINT_HWDETECT
, "Failed to create peripheral key\n"));
1664 DbgPrint((DPRINT_HWDETECT
, "Created key: KeyboardPeripheral\\0\n"));
1666 /* Set 'ComponentInformation' value */
1667 SetComponentInformation(ControllerKey
,
1672 /* Set 'Configuration Data' value */
1673 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
1674 sizeof(CM_KEYBOARD_DEVICE_DATA
);
1675 FullResourceDescriptor
= MmAllocateMemory(Size
);
1676 if (FullResourceDescriptor
== NULL
)
1678 DbgPrint((DPRINT_HWDETECT
,
1679 "Failed to allocate resource descriptor\n"));
1683 /* Initialize resource descriptor */
1684 memset(FullResourceDescriptor
, 0, Size
);
1685 FullResourceDescriptor
->InterfaceType
= Isa
;
1686 FullResourceDescriptor
->BusNumber
= 0;
1687 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
1689 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1690 PartialDescriptor
->Type
= CmResourceTypeDeviceSpecific
;
1691 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1692 PartialDescriptor
->u
.DeviceSpecificData
.DataSize
= sizeof(CM_KEYBOARD_DEVICE_DATA
);
1694 KeyboardData
= (PVOID
)(((ULONG_PTR
)FullResourceDescriptor
) + sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1695 KeyboardData
->Version
= 0;
1696 KeyboardData
->Revision
= 0;
1697 KeyboardData
->Type
= 4;
1698 KeyboardData
->Subtype
= 0;
1699 KeyboardData
->KeyboardFlags
= 0x20;
1701 /* Set 'Configuration Data' value */
1702 Error
= RegSetValue(PeripheralKey
,
1703 "Configuration Data",
1704 REG_FULL_RESOURCE_DESCRIPTOR
,
1705 (PCHAR
)FullResourceDescriptor
,
1707 MmFreeMemory(FullResourceDescriptor
);
1708 if (Error
!= ERROR_SUCCESS
)
1710 DbgPrint((DPRINT_HWDETECT
,
1711 "RegSetValue(Configuration Data) failed (Error %u)\n",
1715 /* Set 'Identifier' value */
1718 Error
= RegSetValue(PeripheralKey
,
1722 strlen(Buffer
) + 1);
1723 if (Error
!= ERROR_SUCCESS
)
1725 DbgPrint((DPRINT_HWDETECT
,
1726 "RegSetValue() failed (Error %u)\n",
1734 DetectKeyboardController(FRLDRHKEY BusKey
)
1736 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1737 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1738 FRLDRHKEY ControllerKey
;
1742 /* Create controller key */
1743 Error
= RegCreateKey(BusKey
,
1744 "KeyboardController\\0",
1746 if (Error
!= ERROR_SUCCESS
)
1748 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1751 DbgPrint((DPRINT_HWDETECT
, "Created key: KeyboardController\\0\n"));
1753 /* Set 'ComponentInformation' value */
1754 SetComponentInformation(ControllerKey
,
1759 /* Set 'Configuration Data' value */
1760 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
1761 2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
1762 FullResourceDescriptor
= MmAllocateMemory(Size
);
1763 if (FullResourceDescriptor
== NULL
)
1765 DbgPrint((DPRINT_HWDETECT
,
1766 "Failed to allocate resource descriptor\n"));
1770 /* Initialize resource descriptor */
1771 memset(FullResourceDescriptor
, 0, Size
);
1772 FullResourceDescriptor
->InterfaceType
= Isa
;
1773 FullResourceDescriptor
->BusNumber
= 0;
1774 FullResourceDescriptor
->PartialResourceList
.Count
= 3;
1777 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1778 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
1779 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1780 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1781 PartialDescriptor
->u
.Interrupt
.Level
= 1;
1782 PartialDescriptor
->u
.Interrupt
.Vector
= 1;
1783 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1785 /* Set IO Port 0x60 */
1786 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
1787 PartialDescriptor
->Type
= CmResourceTypePort
;
1788 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1789 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1790 PartialDescriptor
->u
.Port
.Start
.LowPart
= 0x60;
1791 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1792 PartialDescriptor
->u
.Port
.Length
= 1;
1794 /* Set IO Port 0x64 */
1795 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[2];
1796 PartialDescriptor
->Type
= CmResourceTypePort
;
1797 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1798 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1799 PartialDescriptor
->u
.Port
.Start
.LowPart
= 0x64;
1800 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1801 PartialDescriptor
->u
.Port
.Length
= 1;
1803 /* Set 'Configuration Data' value */
1804 Error
= RegSetValue(ControllerKey
,
1805 "Configuration Data",
1806 REG_FULL_RESOURCE_DESCRIPTOR
,
1807 (PCHAR
)FullResourceDescriptor
,
1809 MmFreeMemory(FullResourceDescriptor
);
1810 if (Error
!= ERROR_SUCCESS
)
1812 DbgPrint((DPRINT_HWDETECT
,
1813 "RegSetValue(Configuration Data) failed (Error %u)\n",
1818 DetectKeyboardPeripheral(ControllerKey
);
1823 PS2ControllerWait(VOID
)
1828 for (Timeout
= 0; Timeout
< CONTROLLER_TIMEOUT
; Timeout
++)
1830 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1831 if ((Status
& CONTROLLER_STATUS_INPUT_BUFFER_FULL
) == 0)
1834 /* Sleep for one millisecond */
1835 StallExecutionProcessor(1000);
1841 DetectPS2AuxPort(VOID
)
1847 /* Put the value 0x5A in the output buffer using the
1848 * "WriteAuxiliary Device Output Buffer" command (0xD3).
1849 * Poll the Status Register for a while to see if the value really turns up
1850 * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1851 * to 1 in the Status Register, we assume this controller has an
1852 * Auxiliary Port (a.k.a. Mouse Port).
1854 PS2ControllerWait();
1855 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_CONTROL
,
1856 CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER
);
1857 PS2ControllerWait();
1859 /* 0x5A is a random dummy value */
1860 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
,
1863 for (Loops
= 0; Loops
< 10; Loops
++)
1865 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1867 if ((Status
& CONTROLLER_STATUS_OUTPUT_BUFFER_FULL
) != 0)
1869 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1870 if ((Status
& CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
) != 0)
1877 StallExecutionProcessor(10000);
1885 DetectPS2AuxDevice(VOID
)
1890 PS2ControllerWait();
1891 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_CONTROL
,
1892 CONTROLLER_COMMAND_WRITE_MOUSE
);
1893 PS2ControllerWait();
1895 /* Identify device */
1896 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
,
1899 StallExecutionProcessor(10000);
1901 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1902 if ((Status
& CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
) == 0)
1907 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1908 if (Scancode
!= 0xFA)
1911 StallExecutionProcessor(10000);
1913 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1914 if ((Status
& CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
) == 0)
1919 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1920 if (Scancode
!= 0x00)
1928 DetectPS2Mouse(FRLDRHKEY BusKey
)
1930 CM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1931 FRLDRHKEY ControllerKey
;
1932 FRLDRHKEY PeripheralKey
;
1935 if (DetectPS2AuxPort())
1937 DbgPrint((DPRINT_HWDETECT
, "Detected PS2 port\n"));
1939 /* Create controller key */
1940 Error
= RegCreateKey(BusKey
,
1941 "PointerController\\0",
1943 if (Error
!= ERROR_SUCCESS
)
1945 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1948 DbgPrint((DPRINT_HWDETECT
, "Created key: PointerController\\0\n"));
1950 /* Set 'ComponentInformation' value */
1951 SetComponentInformation(ControllerKey
,
1956 memset(&FullResourceDescriptor
, 0, sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1958 /* Initialize resource descriptor */
1959 FullResourceDescriptor
.InterfaceType
= Isa
;
1960 FullResourceDescriptor
.BusNumber
= 0;
1961 FullResourceDescriptor
.PartialResourceList
.Count
= 1;
1964 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].Type
= CmResourceTypeInterrupt
;
1965 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].ShareDisposition
= CmResourceShareUndetermined
;
1966 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1967 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].u
.Interrupt
.Level
= 12;
1968 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].u
.Interrupt
.Vector
= 12;
1969 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1971 /* Set 'Configuration Data' value */
1972 Error
= RegSetValue(ControllerKey
,
1973 "Configuration Data",
1974 REG_FULL_RESOURCE_DESCRIPTOR
,
1975 (PCHAR
)&FullResourceDescriptor
,
1976 sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1977 if (Error
!= ERROR_SUCCESS
)
1979 DbgPrint((DPRINT_HWDETECT
,
1980 "RegSetValue(Configuration Data) failed (Error %u)\n",
1986 if (DetectPS2AuxDevice())
1988 DbgPrint((DPRINT_HWDETECT
, "Detected PS2 mouse\n"));
1990 /* Create peripheral key */
1991 Error
= RegCreateKey(ControllerKey
,
1992 "PointerPeripheral\\0",
1994 if (Error
!= ERROR_SUCCESS
)
1996 DbgPrint((DPRINT_HWDETECT
, "Failed to create peripheral key\n"));
1999 DbgPrint((DPRINT_HWDETECT
, "Created key: PointerPeripheral\\0\n"));
2001 /* Set 'ComponentInformation' value */
2002 SetComponentInformation(PeripheralKey
,
2007 /* Initialize resource descriptor */
2008 memset(&FullResourceDescriptor
, 0, sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
2009 FullResourceDescriptor
.InterfaceType
= Isa
;
2010 FullResourceDescriptor
.BusNumber
= 0;
2011 FullResourceDescriptor
.PartialResourceList
.Count
= 0;
2013 /* Set 'Configuration Data' value */
2014 Error
= RegSetValue(PeripheralKey
,
2015 "Configuration Data",
2016 REG_FULL_RESOURCE_DESCRIPTOR
,
2017 (PCHAR
)&FullResourceDescriptor
,
2018 sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) -
2019 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
));
2020 if (Error
!= ERROR_SUCCESS
)
2022 DbgPrint((DPRINT_HWDETECT
,
2023 "RegSetValue(Configuration Data) failed (Error %u)\n",
2028 /* Set 'Identifier' value */
2029 Error
= RegSetValue(PeripheralKey
,
2032 "MICROSOFT PS2 MOUSE",
2034 if (Error
!= ERROR_SUCCESS
)
2036 DbgPrint((DPRINT_HWDETECT
,
2037 "RegSetValue() failed (Error %u)\n",
2047 DetectDisplayController(FRLDRHKEY BusKey
)
2050 FRLDRHKEY ControllerKey
;
2054 Error
= RegCreateKey(BusKey
,
2055 "DisplayController\\0",
2057 if (Error
!= ERROR_SUCCESS
)
2059 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
2062 DbgPrint((DPRINT_HWDETECT
, "Created key: PointerController\\0\n"));
2064 /* Set 'ComponentInformation' value */
2065 SetComponentInformation(ControllerKey
,
2070 /* FIXME: Set 'ComponentInformation' value */
2072 VesaVersion
= BiosIsVesaSupported();
2073 if (VesaVersion
!= 0)
2075 DbgPrint((DPRINT_HWDETECT
,
2076 "VESA version %c.%c\n",
2077 (VesaVersion
>> 8) + '0',
2078 (VesaVersion
& 0xFF) + '0'));
2082 DbgPrint((DPRINT_HWDETECT
,
2083 "VESA not supported\n"));
2086 if (VesaVersion
>= 0x0200)
2097 /* Set 'Identifier' value */
2098 Error
= RegSetValue(ControllerKey
,
2102 strlen(Buffer
) + 1);
2103 if (Error
!= ERROR_SUCCESS
)
2105 DbgPrint((DPRINT_HWDETECT
,
2106 "RegSetValue() failed (Error %u)\n",
2111 /* FIXME: Add display peripheral (monitor) data */
2116 DetectIsaBios(FRLDRHKEY SystemKey
, ULONG
*BusNumber
)
2118 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
2124 /* Create new bus key */
2126 "MultifunctionAdapter\\%u", *BusNumber
);
2127 Error
= RegCreateKey(SystemKey
,
2130 if (Error
!= ERROR_SUCCESS
)
2132 DbgPrint((DPRINT_HWDETECT
, "RegCreateKey() failed (Error %u)\n", (int)Error
));
2136 /* Set 'Component Information' value similar to my NT4 box */
2137 SetComponentInformation(BusKey
,
2142 /* Increment bus number */
2145 /* Set 'Identifier' value */
2146 Error
= RegSetValue(BusKey
,
2151 if (Error
!= ERROR_SUCCESS
)
2153 DbgPrint((DPRINT_HWDETECT
, "RegSetValue() failed (Error %u)\n", (int)Error
));
2157 /* Set 'Configuration Data' value */
2158 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) -
2159 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
2160 FullResourceDescriptor
= MmAllocateMemory(Size
);
2161 if (FullResourceDescriptor
== NULL
)
2163 DbgPrint((DPRINT_HWDETECT
,
2164 "Failed to allocate resource descriptor\n"));
2168 /* Initialize resource descriptor */
2169 memset(FullResourceDescriptor
, 0, Size
);
2170 FullResourceDescriptor
->InterfaceType
= Isa
;
2171 FullResourceDescriptor
->BusNumber
= 0;
2172 FullResourceDescriptor
->PartialResourceList
.Count
= 0;
2174 /* Set 'Configuration Data' value */
2175 Error
= RegSetValue(BusKey
,
2176 "Configuration Data",
2177 REG_FULL_RESOURCE_DESCRIPTOR
,
2178 (PCHAR
) FullResourceDescriptor
,
2180 MmFreeMemory(FullResourceDescriptor
);
2181 if (Error
!= ERROR_SUCCESS
)
2183 DbgPrint((DPRINT_HWDETECT
,
2184 "RegSetValue(Configuration Data) failed (Error %u)\n",
2189 /* Detect ISA/BIOS devices */
2190 DetectBiosDisks(SystemKey
, BusKey
);
2192 DetectBiosFloppyController(SystemKey
, BusKey
);
2194 DetectSerialPorts(BusKey
);
2196 DetectParallelPorts(BusKey
);
2198 DetectKeyboardController(BusKey
);
2200 DetectPS2Mouse(BusKey
);
2202 DetectDisplayController(BusKey
);
2204 /* FIXME: Detect more ISA devices */
2211 FRLDRHKEY SystemKey
;
2212 ULONG BusNumber
= 0;
2215 DbgPrint((DPRINT_HWDETECT
, "DetectHardware()\n"));
2217 /* Create the 'System' key */
2218 Error
= RegCreateKey(NULL
,
2219 "\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
2221 if (Error
!= ERROR_SUCCESS
)
2223 DbgPrint((DPRINT_HWDETECT
, "RegCreateKey() failed (Error %u)\n", (int)Error
));
2230 DetectCPUs(SystemKey
);
2233 DetectPciBios(SystemKey
, &BusNumber
);
2234 DetectApmBios(SystemKey
, &BusNumber
);
2235 DetectPnpBios(SystemKey
, &BusNumber
);
2236 DetectIsaBios(SystemKey
, &BusNumber
);
2237 DetectAcpiBios(SystemKey
, &BusNumber
);
2239 DbgPrint((DPRINT_HWDETECT
, "DetectHardware() Done\n"));
2242 printf("*** System stopped ***\n");