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;
1273 FullResourceDescriptor
.PartialResourceList
.Version
= 1;
1274 FullResourceDescriptor
.PartialResourceList
.Revision
= 1;
1276 Error
= RegSetValue(PeripheralKey
,
1277 L
"Configuration Data",
1278 REG_FULL_RESOURCE_DESCRIPTOR
,
1279 (PCHAR
)&FullResourceDescriptor
,
1280 sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) -
1281 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
));
1282 if (Error
!= ERROR_SUCCESS
)
1284 DbgPrint((DPRINT_HWDETECT
,
1285 "RegSetValue(Configuration Data) failed (Error %u)\n",
1289 /* Set 'Identifier' value */
1290 Error
= RegSetValue(PeripheralKey
,
1294 (wcslen(Identifier
) + 1) * sizeof(WCHAR
));
1295 if (Error
!= ERROR_SUCCESS
)
1297 DbgPrint((DPRINT_HWDETECT
,
1298 "RegSetValue() failed (Error %u)\n",
1306 DetectSerialPorts(FRLDRHKEY BusKey
)
1308 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1309 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1310 PCM_SERIAL_DEVICE_DATA SerialDeviceData
;
1311 ULONG Irq
[4] = {4, 3, 4, 3};
1315 ULONG ControllerNumber
= 0;
1316 FRLDRHKEY ControllerKey
;
1321 DbgPrint((DPRINT_HWDETECT
, "DetectSerialPorts()\n"));
1323 ControllerNumber
= 0;
1324 BasePtr
= (PUSHORT
)0x400;
1325 for (i
= 0; i
< 4; i
++, BasePtr
++)
1327 Base
= (ULONG
)*BasePtr
;
1331 DbgPrint((DPRINT_HWDETECT
,
1332 "Found COM%u port at 0x%x\n",
1336 /* Create controller key */
1338 L
"SerialController\\%u",
1341 Error
= RegCreateKey(BusKey
,
1344 if (Error
!= ERROR_SUCCESS
)
1346 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1349 DbgPrint((DPRINT_HWDETECT
, "Created key: %S\n", Buffer
));
1351 /* Set 'ComponentInformation' value */
1352 SetComponentInformation(ControllerKey
,
1357 /* Build full device descriptor */
1358 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
1359 2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
) +
1360 sizeof(CM_SERIAL_DEVICE_DATA
);
1361 FullResourceDescriptor
= MmAllocateMemory(Size
);
1362 if (FullResourceDescriptor
== NULL
)
1364 DbgPrint((DPRINT_HWDETECT
,
1365 "Failed to allocate resource descriptor\n"));
1368 memset(FullResourceDescriptor
, 0, Size
);
1370 /* Initialize resource descriptor */
1371 FullResourceDescriptor
->InterfaceType
= Isa
;
1372 FullResourceDescriptor
->BusNumber
= 0;
1373 FullResourceDescriptor
->PartialResourceList
.Count
= 3;
1376 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1377 PartialDescriptor
->Type
= CmResourceTypePort
;
1378 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1379 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1380 PartialDescriptor
->u
.Port
.Start
.LowPart
= Base
;
1381 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1382 PartialDescriptor
->u
.Port
.Length
= 7;
1385 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
1386 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
1387 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1388 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1389 PartialDescriptor
->u
.Interrupt
.Level
= Irq
[i
];
1390 PartialDescriptor
->u
.Interrupt
.Vector
= Irq
[i
];
1391 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1393 /* Set serial data (device specific) */
1394 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[2];
1395 PartialDescriptor
->Type
= CmResourceTypeDeviceSpecific
;
1396 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1397 PartialDescriptor
->Flags
= 0;
1398 PartialDescriptor
->u
.DeviceSpecificData
.DataSize
= sizeof(CM_SERIAL_DEVICE_DATA
);
1401 (PCM_SERIAL_DEVICE_DATA
)&FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[3];
1402 SerialDeviceData
->BaudClock
= 1843200; /* UART Clock frequency (Hertz) */
1404 /* Set 'Configuration Data' value */
1405 Error
= RegSetValue(ControllerKey
,
1406 L
"Configuration Data",
1407 REG_FULL_RESOURCE_DESCRIPTOR
,
1408 (PCHAR
) FullResourceDescriptor
,
1410 MmFreeMemory(FullResourceDescriptor
);
1411 if (Error
!= ERROR_SUCCESS
)
1413 DbgPrint((DPRINT_HWDETECT
,
1414 "RegSetValue(Configuration Data) failed (Error %u)\n",
1418 /* Set 'Identifier' value */
1422 Error
= RegSetValue(ControllerKey
,
1426 (wcslen(Buffer
) + 1) * sizeof(WCHAR
));
1427 if (Error
!= ERROR_SUCCESS
)
1429 DbgPrint((DPRINT_HWDETECT
,
1430 "RegSetValue() failed (Error %u)\n",
1434 DbgPrint((DPRINT_HWDETECT
,
1435 "Created value: Identifier %s\n",
1438 if (!Rs232PortInUse(Base
))
1440 /* Detect serial mouse */
1441 DetectSerialPointerPeripheral(ControllerKey
, Base
);
1450 DetectParallelPorts(FRLDRHKEY BusKey
)
1452 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1453 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1454 ULONG Irq
[3] = {7, 5, (ULONG
)-1};
1456 FRLDRHKEY ControllerKey
;
1459 ULONG ControllerNumber
;
1464 DbgPrint((DPRINT_HWDETECT
, "DetectParallelPorts() called\n"));
1466 ControllerNumber
= 0;
1467 BasePtr
= (PUSHORT
)0x408;
1468 for (i
= 0; i
< 3; i
++, BasePtr
++)
1470 Base
= (ULONG
)*BasePtr
;
1474 DbgPrint((DPRINT_HWDETECT
,
1475 "Parallel port %u: %x\n",
1479 /* Create controller key */
1481 L
"ParallelController\\%u",
1484 Error
= RegCreateKey(BusKey
,
1487 if (Error
!= ERROR_SUCCESS
)
1489 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1492 DbgPrint((DPRINT_HWDETECT
, "Created key: %S\n", Buffer
));
1494 /* Set 'ComponentInformation' value */
1495 SetComponentInformation(ControllerKey
,
1500 /* Build full device descriptor */
1501 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
);
1502 if (Irq
[i
] != (ULONG
)-1)
1503 Size
+= sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
1505 FullResourceDescriptor
= MmAllocateMemory(Size
);
1506 if (FullResourceDescriptor
== NULL
)
1508 DbgPrint((DPRINT_HWDETECT
,
1509 "Failed to allocate resource descriptor\n"));
1512 memset(FullResourceDescriptor
, 0, Size
);
1514 /* Initialize resource descriptor */
1515 FullResourceDescriptor
->InterfaceType
= Isa
;
1516 FullResourceDescriptor
->BusNumber
= 0;
1517 FullResourceDescriptor
->PartialResourceList
.Count
= (Irq
[i
] != (ULONG
)-1) ? 2 : 1;
1520 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1521 PartialDescriptor
->Type
= CmResourceTypePort
;
1522 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1523 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1524 PartialDescriptor
->u
.Port
.Start
.LowPart
= Base
;
1525 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1526 PartialDescriptor
->u
.Port
.Length
= 3;
1529 if (Irq
[i
] != (ULONG
)-1)
1531 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
1532 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
1533 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1534 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1535 PartialDescriptor
->u
.Interrupt
.Level
= Irq
[i
];
1536 PartialDescriptor
->u
.Interrupt
.Vector
= Irq
[i
];
1537 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1540 /* Set 'Configuration Data' value */
1541 Error
= RegSetValue(ControllerKey
,
1542 L
"Configuration Data",
1543 REG_FULL_RESOURCE_DESCRIPTOR
,
1544 (PCHAR
) FullResourceDescriptor
,
1546 MmFreeMemory(FullResourceDescriptor
);
1547 if (Error
!= ERROR_SUCCESS
)
1549 DbgPrint((DPRINT_HWDETECT
,
1550 "RegSetValue(Configuration Data) failed (Error %u)\n",
1554 /* Set 'Identifier' value */
1558 Error
= RegSetValue(ControllerKey
,
1562 (wcslen(Buffer
) + 1) * sizeof(WCHAR
));
1563 if (Error
!= ERROR_SUCCESS
)
1565 DbgPrint((DPRINT_HWDETECT
,
1566 "RegSetValue() failed (Error %u)\n",
1570 DbgPrint((DPRINT_HWDETECT
,
1571 "Created value: Identifier %s\n",
1577 DbgPrint((DPRINT_HWDETECT
, "DetectParallelPorts() done\n"));
1582 DetectKeyboardDevice(VOID
)
1587 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
,
1590 StallExecutionProcessor(10000);
1592 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1593 if ((Status
& 0x01) != 0x01)
1595 /* PC/XT keyboard or no keyboard */
1599 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1600 if (Scancode
!= 0xFA)
1602 /* No ACK received */
1606 StallExecutionProcessor(10000);
1607 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1608 if ((Status
& 0x01) != 0x01)
1610 /* Found AT keyboard */
1614 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1615 if (Scancode
!= 0xAB)
1617 /* No 0xAB received */
1621 StallExecutionProcessor(10000);
1622 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1623 if ((Status
& 0x01) != 0x01)
1625 /* No byte in buffer */
1629 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1630 if (Scancode
!= 0x41)
1632 /* No 0x41 received */
1636 /* Found MF-II keyboard */
1642 DetectKeyboardPeripheral(FRLDRHKEY ControllerKey
)
1644 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1645 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1646 PCM_KEYBOARD_DEVICE_DATA KeyboardData
;
1647 FRLDRHKEY PeripheralKey
;
1651 if (DetectKeyboardDevice())
1653 /* Create controller key */
1654 Error
= RegCreateKey(ControllerKey
,
1655 L
"KeyboardPeripheral\\0",
1657 if (Error
!= ERROR_SUCCESS
)
1659 DbgPrint((DPRINT_HWDETECT
, "Failed to create peripheral key\n"));
1662 DbgPrint((DPRINT_HWDETECT
, "Created key: KeyboardPeripheral\\0\n"));
1664 /* Set 'ComponentInformation' value */
1665 SetComponentInformation(ControllerKey
,
1670 /* Set 'Configuration Data' value */
1671 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
1672 sizeof(CM_KEYBOARD_DEVICE_DATA
);
1673 FullResourceDescriptor
= MmAllocateMemory(Size
);
1674 if (FullResourceDescriptor
== NULL
)
1676 DbgPrint((DPRINT_HWDETECT
,
1677 "Failed to allocate resource descriptor\n"));
1681 /* Initialize resource descriptor */
1682 memset(FullResourceDescriptor
, 0, Size
);
1683 FullResourceDescriptor
->InterfaceType
= Isa
;
1684 FullResourceDescriptor
->BusNumber
= 0;
1685 FullResourceDescriptor
->PartialResourceList
.Count
= 1;
1687 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1688 PartialDescriptor
->Type
= CmResourceTypeDeviceSpecific
;
1689 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1690 PartialDescriptor
->u
.DeviceSpecificData
.DataSize
= sizeof(CM_KEYBOARD_DEVICE_DATA
);
1692 KeyboardData
= (PVOID
)(((ULONG_PTR
)FullResourceDescriptor
) + sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1693 KeyboardData
->Version
= 1;
1694 KeyboardData
->Revision
= 1;
1695 KeyboardData
->Type
= 4;
1696 KeyboardData
->Subtype
= 0;
1697 KeyboardData
->KeyboardFlags
= 0x20;
1699 /* Set 'Configuration Data' value */
1700 Error
= RegSetValue(PeripheralKey
,
1701 L
"Configuration Data",
1702 REG_FULL_RESOURCE_DESCRIPTOR
,
1703 (PCHAR
)FullResourceDescriptor
,
1705 MmFreeMemory(FullResourceDescriptor
);
1706 if (Error
!= ERROR_SUCCESS
)
1708 DbgPrint((DPRINT_HWDETECT
,
1709 "RegSetValue(Configuration Data) failed (Error %u)\n",
1713 /* Set 'Identifier' value */
1714 Error
= RegSetValue(PeripheralKey
,
1717 (PCHAR
)L
"PCAT_ENHANCED",
1718 14 * sizeof(WCHAR
));
1719 if (Error
!= ERROR_SUCCESS
)
1721 DbgPrint((DPRINT_HWDETECT
,
1722 "RegSetValue() failed (Error %u)\n",
1730 DetectKeyboardController(FRLDRHKEY BusKey
)
1732 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1733 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor
;
1734 FRLDRHKEY ControllerKey
;
1738 /* Create controller key */
1739 Error
= RegCreateKey(BusKey
,
1740 L
"KeyboardController\\0",
1742 if (Error
!= ERROR_SUCCESS
)
1744 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1747 DbgPrint((DPRINT_HWDETECT
, "Created key: KeyboardController\\0\n"));
1749 /* Set 'ComponentInformation' value */
1750 SetComponentInformation(ControllerKey
,
1755 /* Set 'Configuration Data' value */
1756 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) +
1757 2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
1758 FullResourceDescriptor
= MmAllocateMemory(Size
);
1759 if (FullResourceDescriptor
== NULL
)
1761 DbgPrint((DPRINT_HWDETECT
,
1762 "Failed to allocate resource descriptor\n"));
1766 /* Initialize resource descriptor */
1767 memset(FullResourceDescriptor
, 0, Size
);
1768 FullResourceDescriptor
->InterfaceType
= Isa
;
1769 FullResourceDescriptor
->BusNumber
= 0;
1770 FullResourceDescriptor
->PartialResourceList
.Count
= 3;
1773 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[0];
1774 PartialDescriptor
->Type
= CmResourceTypeInterrupt
;
1775 PartialDescriptor
->ShareDisposition
= CmResourceShareUndetermined
;
1776 PartialDescriptor
->Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1777 PartialDescriptor
->u
.Interrupt
.Level
= 1;
1778 PartialDescriptor
->u
.Interrupt
.Vector
= 1;
1779 PartialDescriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1781 /* Set IO Port 0x60 */
1782 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[1];
1783 PartialDescriptor
->Type
= CmResourceTypePort
;
1784 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1785 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1786 PartialDescriptor
->u
.Port
.Start
.LowPart
= 0x60;
1787 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1788 PartialDescriptor
->u
.Port
.Length
= 1;
1790 /* Set IO Port 0x64 */
1791 PartialDescriptor
= &FullResourceDescriptor
->PartialResourceList
.PartialDescriptors
[2];
1792 PartialDescriptor
->Type
= CmResourceTypePort
;
1793 PartialDescriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
1794 PartialDescriptor
->Flags
= CM_RESOURCE_PORT_IO
;
1795 PartialDescriptor
->u
.Port
.Start
.LowPart
= 0x64;
1796 PartialDescriptor
->u
.Port
.Start
.HighPart
= 0x0;
1797 PartialDescriptor
->u
.Port
.Length
= 1;
1799 /* Set 'Configuration Data' value */
1800 Error
= RegSetValue(ControllerKey
,
1801 L
"Configuration Data",
1802 REG_FULL_RESOURCE_DESCRIPTOR
,
1803 (PCHAR
)FullResourceDescriptor
,
1805 MmFreeMemory(FullResourceDescriptor
);
1806 if (Error
!= ERROR_SUCCESS
)
1808 DbgPrint((DPRINT_HWDETECT
,
1809 "RegSetValue(Configuration Data) failed (Error %u)\n",
1814 DetectKeyboardPeripheral(ControllerKey
);
1819 PS2ControllerWait(VOID
)
1824 for (Timeout
= 0; Timeout
< CONTROLLER_TIMEOUT
; Timeout
++)
1826 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1827 if ((Status
& CONTROLLER_STATUS_INPUT_BUFFER_FULL
) == 0)
1830 /* Sleep for one millisecond */
1831 StallExecutionProcessor(1000);
1837 DetectPS2AuxPort(VOID
)
1843 /* Put the value 0x5A in the output buffer using the
1844 * "WriteAuxiliary Device Output Buffer" command (0xD3).
1845 * Poll the Status Register for a while to see if the value really turns up
1846 * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1847 * to 1 in the Status Register, we assume this controller has an
1848 * Auxiliary Port (a.k.a. Mouse Port).
1850 PS2ControllerWait();
1851 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_CONTROL
,
1852 CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER
);
1853 PS2ControllerWait();
1855 /* 0x5A is a random dummy value */
1856 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
,
1859 for (Loops
= 0; Loops
< 10; Loops
++)
1861 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1863 if ((Status
& CONTROLLER_STATUS_OUTPUT_BUFFER_FULL
) != 0)
1865 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1866 if ((Status
& CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
) != 0)
1873 StallExecutionProcessor(10000);
1881 DetectPS2AuxDevice(VOID
)
1886 PS2ControllerWait();
1887 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_CONTROL
,
1888 CONTROLLER_COMMAND_WRITE_MOUSE
);
1889 PS2ControllerWait();
1891 /* Identify device */
1892 WRITE_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
,
1895 StallExecutionProcessor(10000);
1897 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1898 if ((Status
& CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
) == 0)
1903 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1904 if (Scancode
!= 0xFA)
1907 StallExecutionProcessor(10000);
1909 Status
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_STATUS
);
1910 if ((Status
& CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
) == 0)
1915 Scancode
= READ_PORT_UCHAR((PUCHAR
)CONTROLLER_REGISTER_DATA
);
1916 if (Scancode
!= 0x00)
1924 DetectPS2Mouse(FRLDRHKEY BusKey
)
1926 CM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
1927 FRLDRHKEY ControllerKey
;
1928 FRLDRHKEY PeripheralKey
;
1931 if (DetectPS2AuxPort())
1933 DbgPrint((DPRINT_HWDETECT
, "Detected PS2 port\n"));
1935 /* Create controller key */
1936 Error
= RegCreateKey(BusKey
,
1937 L
"PointerController\\0",
1939 if (Error
!= ERROR_SUCCESS
)
1941 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
1944 DbgPrint((DPRINT_HWDETECT
, "Created key: PointerController\\0\n"));
1946 /* Set 'ComponentInformation' value */
1947 SetComponentInformation(ControllerKey
,
1952 memset(&FullResourceDescriptor
, 0, sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1954 /* Initialize resource descriptor */
1955 FullResourceDescriptor
.InterfaceType
= Isa
;
1956 FullResourceDescriptor
.BusNumber
= 0;
1957 FullResourceDescriptor
.PartialResourceList
.Count
= 1;
1960 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].Type
= CmResourceTypeInterrupt
;
1961 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].ShareDisposition
= CmResourceShareUndetermined
;
1962 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].Flags
= CM_RESOURCE_INTERRUPT_LATCHED
;
1963 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].u
.Interrupt
.Level
= 12;
1964 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].u
.Interrupt
.Vector
= 12;
1965 FullResourceDescriptor
.PartialResourceList
.PartialDescriptors
[0].u
.Interrupt
.Affinity
= 0xFFFFFFFF;
1967 /* Set 'Configuration Data' value */
1968 Error
= RegSetValue(ControllerKey
,
1969 L
"Configuration Data",
1970 REG_FULL_RESOURCE_DESCRIPTOR
,
1971 (PCHAR
)&FullResourceDescriptor
,
1972 sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
1973 if (Error
!= ERROR_SUCCESS
)
1975 DbgPrint((DPRINT_HWDETECT
,
1976 "RegSetValue(Configuration Data) failed (Error %u)\n",
1982 if (DetectPS2AuxDevice())
1984 DbgPrint((DPRINT_HWDETECT
, "Detected PS2 mouse\n"));
1986 /* Create peripheral key */
1987 Error
= RegCreateKey(ControllerKey
,
1988 L
"PointerPeripheral\\0",
1990 if (Error
!= ERROR_SUCCESS
)
1992 DbgPrint((DPRINT_HWDETECT
, "Failed to create peripheral key\n"));
1995 DbgPrint((DPRINT_HWDETECT
, "Created key: PointerPeripheral\\0\n"));
1997 /* Set 'ComponentInformation' value */
1998 SetComponentInformation(PeripheralKey
,
2003 /* Initialize resource descriptor */
2004 memset(&FullResourceDescriptor
, 0, sizeof(CM_FULL_RESOURCE_DESCRIPTOR
));
2005 FullResourceDescriptor
.InterfaceType
= Isa
;
2006 FullResourceDescriptor
.BusNumber
= 0;
2007 FullResourceDescriptor
.PartialResourceList
.Count
= 0;
2009 /* Set 'Configuration Data' value */
2010 Error
= RegSetValue(PeripheralKey
,
2011 L
"Configuration Data",
2012 REG_FULL_RESOURCE_DESCRIPTOR
,
2013 (PCHAR
)&FullResourceDescriptor
,
2014 sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) -
2015 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
));
2016 if (Error
!= ERROR_SUCCESS
)
2018 DbgPrint((DPRINT_HWDETECT
,
2019 "RegSetValue(Configuration Data) failed (Error %u)\n",
2024 /* Set 'Identifier' value */
2025 Error
= RegSetValue(PeripheralKey
,
2028 (PCHAR
)L
"MICROSOFT PS2 MOUSE",
2029 20 * sizeof(WCHAR
));
2030 if (Error
!= ERROR_SUCCESS
)
2032 DbgPrint((DPRINT_HWDETECT
,
2033 "RegSetValue() failed (Error %u)\n",
2043 DetectDisplayController(FRLDRHKEY BusKey
)
2046 FRLDRHKEY ControllerKey
;
2050 Error
= RegCreateKey(BusKey
,
2051 L
"DisplayController\\0",
2053 if (Error
!= ERROR_SUCCESS
)
2055 DbgPrint((DPRINT_HWDETECT
, "Failed to create controller key\n"));
2058 DbgPrint((DPRINT_HWDETECT
, "Created key: PointerController\\0\n"));
2060 /* Set 'ComponentInformation' value */
2061 SetComponentInformation(ControllerKey
,
2066 /* FIXME: Set 'ComponentInformation' value */
2068 VesaVersion
= BiosIsVesaSupported();
2069 if (VesaVersion
!= 0)
2071 DbgPrint((DPRINT_HWDETECT
,
2072 "VESA version %c.%c\n",
2073 (VesaVersion
>> 8) + '0',
2074 (VesaVersion
& 0xFF) + '0'));
2078 DbgPrint((DPRINT_HWDETECT
,
2079 "VESA not supported\n"));
2082 if (VesaVersion
>= 0x0200)
2093 /* Set 'Identifier' value */
2094 Error
= RegSetValue(ControllerKey
,
2098 (wcslen(Buffer
) + 1) * sizeof(WCHAR
));
2099 if (Error
!= ERROR_SUCCESS
)
2101 DbgPrint((DPRINT_HWDETECT
,
2102 "RegSetValue() failed (Error %u)\n",
2107 /* FIXME: Add display peripheral (monitor) data */
2112 DetectIsaBios(FRLDRHKEY SystemKey
, ULONG
*BusNumber
)
2114 PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor
;
2120 /* Create new bus key */
2122 L
"MultifunctionAdapter\\%u", *BusNumber
);
2123 Error
= RegCreateKey(SystemKey
,
2126 if (Error
!= ERROR_SUCCESS
)
2128 DbgPrint((DPRINT_HWDETECT
, "RegCreateKey() failed (Error %u)\n", (int)Error
));
2132 /* Set 'Component Information' value similar to my NT4 box */
2133 SetComponentInformation(BusKey
,
2138 /* Increment bus number */
2141 /* Set 'Identifier' value */
2142 Error
= RegSetValue(BusKey
,
2147 if (Error
!= ERROR_SUCCESS
)
2149 DbgPrint((DPRINT_HWDETECT
, "RegSetValue() failed (Error %u)\n", (int)Error
));
2153 /* Set 'Configuration Data' value */
2154 Size
= sizeof(CM_FULL_RESOURCE_DESCRIPTOR
) -
2155 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
2156 FullResourceDescriptor
= MmAllocateMemory(Size
);
2157 if (FullResourceDescriptor
== NULL
)
2159 DbgPrint((DPRINT_HWDETECT
,
2160 "Failed to allocate resource descriptor\n"));
2164 /* Initialize resource descriptor */
2165 memset(FullResourceDescriptor
, 0, Size
);
2166 FullResourceDescriptor
->InterfaceType
= Isa
;
2167 FullResourceDescriptor
->BusNumber
= 0;
2168 FullResourceDescriptor
->PartialResourceList
.Count
= 0;
2170 /* Set 'Configuration Data' value */
2171 Error
= RegSetValue(BusKey
,
2172 L
"Configuration Data",
2173 REG_FULL_RESOURCE_DESCRIPTOR
,
2174 (PCHAR
) FullResourceDescriptor
,
2176 MmFreeMemory(FullResourceDescriptor
);
2177 if (Error
!= ERROR_SUCCESS
)
2179 DbgPrint((DPRINT_HWDETECT
,
2180 "RegSetValue(Configuration Data) failed (Error %u)\n",
2185 /* Detect ISA/BIOS devices */
2186 DetectBiosDisks(SystemKey
, BusKey
);
2188 DetectBiosFloppyController(SystemKey
, BusKey
);
2190 DetectSerialPorts(BusKey
);
2192 DetectParallelPorts(BusKey
);
2194 DetectKeyboardController(BusKey
);
2196 DetectPS2Mouse(BusKey
);
2198 DetectDisplayController(BusKey
);
2200 /* FIXME: Detect more ISA devices */
2207 FRLDRHKEY SystemKey
;
2208 ULONG BusNumber
= 0;
2211 DbgPrint((DPRINT_HWDETECT
, "DetectHardware()\n"));
2213 /* Create the 'System' key */
2214 Error
= RegCreateKey(NULL
,
2215 L
"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
2217 if (Error
!= ERROR_SUCCESS
)
2219 DbgPrint((DPRINT_HWDETECT
, "RegCreateKey() failed (Error %u)\n", (int)Error
));
2226 DetectCPUs(SystemKey
);
2229 DetectPciBios(SystemKey
, &BusNumber
);
2230 DetectApmBios(SystemKey
, &BusNumber
);
2231 DetectPnpBios(SystemKey
, &BusNumber
);
2232 DetectIsaBios(SystemKey
, &BusNumber
);
2233 DetectAcpiBios(SystemKey
, &BusNumber
);
2235 DbgPrint((DPRINT_HWDETECT
, "DetectHardware() Done\n"));
2238 printf("*** System stopped ***\n");