ReactOS 0.4.16-dev-2284-g3529151
machpc.c
Go to the documentation of this file.
1/*
2 * FreeLoader
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#include <freeldr.h>
20#include <cportlib/cportlib.h>
21
22#include "../ntldr/ntldropts.h"
23
24#include <debug.h>
26
27
28/* Maximum number of COM and LPT ports */
29#define MAX_COM_PORTS 4
30#define MAX_LPT_PORTS 3
31
32/* No Mouse */
33#define MOUSE_TYPE_NONE 0
34/* Microsoft Mouse with 2 buttons */
35#define MOUSE_TYPE_MICROSOFT 1
36/* Logitech Mouse with 3 buttons */
37#define MOUSE_TYPE_LOGITECH 2
38/* Microsoft Wheel Mouse (aka Z Mouse) */
39#define MOUSE_TYPE_WHEELZ 3
40/* Mouse Systems Mouse */
41#define MOUSE_TYPE_MOUSESYSTEMS 4
42
43#define INPORT_REGISTER_CONTROL 0x00
44#define INPORT_REGISTER_DATA 0x01
45#define INPORT_REGISTER_SIGNATURE 0x02
46
47#define INPORT_REG_MODE 0x07
48#define INPORT_RESET 0x80
49#define INPORT_MODE_BASE 0x10
50#define INPORT_TEST_IRQ 0x16
51#define INPORT_SIGNATURE 0xDE
52
53#define PIC1_CONTROL_PORT 0x20
54#define PIC1_DATA_PORT 0x21
55#define PIC2_CONTROL_PORT 0xA0
56#define PIC2_DATA_PORT 0xA1
57
58/* PS2 stuff */
59
60/* Controller registers. */
61#define CONTROLLER_REGISTER_STATUS 0x64
62#define CONTROLLER_REGISTER_CONTROL 0x64
63#define CONTROLLER_REGISTER_DATA 0x60
64
65/* Controller commands. */
66#define CONTROLLER_COMMAND_READ_MODE 0x20
67#define CONTROLLER_COMMAND_WRITE_MODE 0x60
68#define CONTROLLER_COMMAND_GET_VERSION 0xA1
69#define CONTROLLER_COMMAND_MOUSE_DISABLE 0xA7
70#define CONTROLLER_COMMAND_MOUSE_ENABLE 0xA8
71#define CONTROLLER_COMMAND_TEST_MOUSE 0xA9
72#define CONTROLLER_COMMAND_SELF_TEST 0xAA
73#define CONTROLLER_COMMAND_KEYBOARD_TEST 0xAB
74#define CONTROLLER_COMMAND_KEYBOARD_DISABLE 0xAD
75#define CONTROLLER_COMMAND_KEYBOARD_ENABLE 0xAE
76#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER 0xD3
77#define CONTROLLER_COMMAND_WRITE_MOUSE 0xD4
78
79/* Controller status */
80#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL 0x01
81#define CONTROLLER_STATUS_INPUT_BUFFER_FULL 0x02
82#define CONTROLLER_STATUS_SELF_TEST 0x04
83#define CONTROLLER_STATUS_COMMAND 0x08
84#define CONTROLLER_STATUS_UNLOCKED 0x10
85#define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL 0x20
86#define CONTROLLER_STATUS_GENERAL_TIMEOUT 0x40
87#define CONTROLLER_STATUS_PARITY_ERROR 0x80
88#define AUX_STATUS_OUTPUT_BUFFER_FULL (CONTROLLER_STATUS_OUTPUT_BUFFER_FULL | \
89 CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL)
90
91/* Timeout in ms for sending to keyboard controller. */
92#define CONTROLLER_TIMEOUT 250
93
94#include <pshpack1.h>
95typedef struct _PNP_DOCK_INFO
96{
101#include <poppack.h>
102
103/* FIXME: Abstract things better so we don't need to place define here */
104#if !defined(SARCH_XBOX)
105
106VOID
108{
109 REGS BiosRegs;
110
111 /* Get address and size of the extended BIOS data area */
112 BiosRegs.d.eax = 0xC100;
113 Int386(0x15, &BiosRegs, &BiosRegs);
114 if (INT386_SUCCESS(BiosRegs))
115 {
116 *ExtendedBIOSDataArea = BiosRegs.w.es << 4;
117 *ExtendedBIOSDataSize = 1024;
118 }
119 else
120 {
121 WARN("Int 15h AH=C1h call failed\n");
124 }
125}
126
127// NOTE: Similar to machxbox.c!XboxGetHarddiskConfigurationData(),
128// but with extended geometry support.
129static
132{
133 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
135 GEOMETRY Geometry;
136 ULONG Size;
137
138 /* Initialize returned size */
139 *pSize = 0;
140
141 /* Set 'Configuration Data' value */
142 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]) + sizeof(*DiskGeometry);
143 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
144 if (PartialResourceList == NULL)
145 {
146 ERR("Failed to allocate resource descriptor\n");
147 return NULL;
148 }
149
150 RtlZeroMemory(PartialResourceList, Size);
151 PartialResourceList->Version = 1;
152 PartialResourceList->Revision = 1;
153 PartialResourceList->Count = 1;
154 PartialResourceList->PartialDescriptors[0].Type =
156// PartialResourceList->PartialDescriptors[0].ShareDisposition =
157// PartialResourceList->PartialDescriptors[0].Flags =
158 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
159 sizeof(*DiskGeometry);
160
161 /* Get the disk geometry */
162 DiskGeometry = (PCM_DISK_GEOMETRY_DEVICE_DATA)&PartialResourceList->PartialDescriptors[1];
163 if (PcDiskGetDriveGeometry(DriveNumber, &Geometry))
164 {
165 DiskGeometry->BytesPerSector = Geometry.BytesPerSector;
166 DiskGeometry->NumberOfCylinders = Geometry.Cylinders;
167 DiskGeometry->SectorsPerTrack = Geometry.SectorsPerTrack;
168 DiskGeometry->NumberOfHeads = Geometry.Heads;
169 }
170 else
171 {
172 TRACE("Reading disk geometry failed\n");
173 FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
174 return NULL;
175 }
176 TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
177 DriveNumber,
178 DiskGeometry->NumberOfCylinders,
179 DiskGeometry->NumberOfHeads,
180 DiskGeometry->SectorsPerTrack,
181 DiskGeometry->BytesPerSector);
182
183 /* Return configuration data */
184 *pSize = Size;
185 return PartialResourceList;
186}
187
188static
189VOID
192{
193 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
194 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
195 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
196 PDOCKING_STATE_INFORMATION DockingState;
197 PPNP_DOCK_INFO DockInfo;
199
201
202 /* Build full device descriptor */
203 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]) + sizeof(*DockingState);
204 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
205 if (PartialResourceList == NULL)
206 {
207 ERR("Failed to allocate resource descriptor\n");
208 return;
209 }
210
211 /* Initialize resource descriptor */
212 RtlZeroMemory(PartialResourceList, Size);
213 PartialResourceList->Version = 0;
214 PartialResourceList->Revision = 0;
215 PartialResourceList->Count = 1;
216
217 /* Set device specific data */
218 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
219 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
221 PartialDescriptor->Flags = 0;
222 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(*DockingState);
223
224 DockingState = (PDOCKING_STATE_INFORMATION)(PartialDescriptor + 1);
225 DockingState->ReturnCode = Result;
226 if (Result == 0)
227 {
228 DockInfo = (PPNP_DOCK_INFO)DiskReadBuffer;
229 DockingState->DockLocationID = DockInfo->DockLocationID;
230 DockingState->SerialNumber = DockInfo->SerialNumber;
231 DockingState->Capabilities = DockInfo->Capabilities;
232 TRACE("System docked\n");
233 TRACE("Location: 0x%08lx\n", DockInfo->DockLocationID);
234 TRACE("Serial: 0x%08lx\n", DockInfo->SerialNumber);
235 TRACE("Capabilities: 0x%04hx\n", DockInfo->Capabilities);
236 }
237
238 /* Create controller key */
242 0,
243 0,
244 0xFFFFFFFF,
245 "Docking State Information",
246 PartialResourceList,
247 Size,
248 &PeripheralKey);
249}
250
251static
252VOID
254{
255 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
259 ULONG x;
260 ULONG NodeSize = 0;
261 ULONG NodeCount = 0;
263 ULONG FoundNodeCount;
264 int i;
265 ULONG PnpBufferSize;
266 ULONG PnpBufferSizeLimit;
267 ULONG Size;
268 char* Ptr;
269
271 if (InstData == NULL || strncmp((CHAR*)InstData->Signature, "$PnP", 4))
272 {
273 TRACE("PnP-BIOS not supported\n");
274 return;
275 }
276
277 TRACE("PnP-BIOS supported\n");
278 TRACE("Signature '%c%c%c%c'\n",
279 InstData->Signature[0], InstData->Signature[1],
280 InstData->Signature[2], InstData->Signature[3]);
281
282 x = PnpBiosGetDeviceNodeCount(&NodeSize, &NodeCount);
283 if (x == 0x82)
284 {
285 TRACE("PnP-BIOS function 'Get Number of System Device Nodes' not supported\n");
286 return;
287 }
288
289 NodeCount &= 0xFF; // needed since some fscked up BIOSes return wrong info (e.g. Mac Virtual PC)
290 // e.g. look: https://web.archive.org/web/20080329010332/http://my.execpc.com/~geezer/osd/pnp/pnp16.c
291 if (x != 0 || NodeSize == 0 || NodeCount == 0)
292 {
293 ERR("PnP-BIOS failed to enumerate device nodes\n");
294 return;
295 }
296 TRACE("MaxNodeSize %u NodeCount %u\n", NodeSize, NodeCount);
297 TRACE("Estimated buffer size %u\n", NodeSize * NodeCount);
298
299 /* Set 'Configuration Data' value */
300 PnpBufferSizeLimit = sizeof(*InstData) + (NodeSize * NodeCount);
301 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]) + PnpBufferSizeLimit;
302 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
303 if (PartialResourceList == NULL)
304 {
305 ERR("Failed to allocate resource descriptor\n");
306 return;
307 }
308
309 /* Initialize resource descriptor */
310 RtlZeroMemory(PartialResourceList, Size);
311 PartialResourceList->Version = 1;
312 PartialResourceList->Revision = 1;
313 PartialResourceList->Count = 1;
314 PartialResourceList->PartialDescriptors[0].Type =
316 PartialResourceList->PartialDescriptors[0].ShareDisposition =
318
319 /* Set installation check data */
320 Ptr = (char*)&PartialResourceList->PartialDescriptors[1];
321 RtlCopyMemory(Ptr, InstData, sizeof(*InstData));
322 Ptr += sizeof(*InstData);
323 PnpBufferSize = sizeof(*InstData);
324
325 /* Copy device nodes */
326 FoundNodeCount = 0;
327 for (i = 0; i < 0xFF; i++)
328 {
329 NodeNumber = (UCHAR)i;
330
332 if (x == 0)
333 {
335
336 TRACE("Node: %u Size %u (0x%x)\n",
337 DeviceNode->Node,
338 DeviceNode->Size,
339 DeviceNode->Size);
340
341 if (PnpBufferSize + DeviceNode->Size > PnpBufferSizeLimit)
342 {
343 ERR("Buffer too small! Ignoring remaining device nodes. (i = %d)\n", i);
344 break;
345 }
346
348
349 Ptr += DeviceNode->Size;
350 PnpBufferSize += DeviceNode->Size;
351
352 FoundNodeCount++;
353 if (FoundNodeCount >= NodeCount)
354 break;
355 }
356 }
357
358 /* Set real data size */
359 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
360 PnpBufferSize;
361 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]) + PnpBufferSize;
362
363 TRACE("Real buffer size: %u\n", PnpBufferSize);
364 TRACE("Resource size: %u\n", Size);
365
366 /* Create component key */
367 FldrCreateComponentKey(SystemKey,
370 0,
371 0,
372 0xFFFFFFFF,
373 "PNP BIOS",
374 PartialResourceList,
375 Size,
376 &BusKey);
377
378 DetectDockingStation(BusKey);
379
380 (*BusNumber)++;
381}
382
383#endif // !SARCH_XBOX
384
385static
386VOID
388 UCHAR LineControl)
389{
390 WRITE_PORT_UCHAR(Port + 3, 0x80); /* set DLAB on */
391 WRITE_PORT_UCHAR(Port, 0x60); /* speed LO byte */
392 WRITE_PORT_UCHAR(Port + 1, 0); /* speed HI byte */
393 WRITE_PORT_UCHAR(Port + 3, LineControl);
394 WRITE_PORT_UCHAR(Port + 1, 0); /* set comm and DLAB to 0 */
395 WRITE_PORT_UCHAR(Port + 4, 0x09); /* DR int enable */
396 READ_PORT_UCHAR(Port + 5); /* clear error bits */
397}
398
399static
400ULONG
402{
403 CHAR Buffer[4];
404 ULONG i;
405 ULONG TimeOut;
406 UCHAR LineControl;
407
408 /* Shutdown mouse or something like that */
409 LineControl = READ_PORT_UCHAR(Port + 4);
410 WRITE_PORT_UCHAR(Port + 4, (LineControl & ~0x02) | 0x01);
412
413 /*
414 * Clear buffer
415 * Maybe there is no serial port although BIOS reported one (this
416 * is the case on Apple hardware), or the serial port is misbehaving,
417 * therefore we must give up after some time.
418 */
419 TimeOut = 200;
420 while (READ_PORT_UCHAR(Port + 5) & 0x01)
421 {
422 if (--TimeOut == 0)
423 return MOUSE_TYPE_NONE;
425 }
426
427 /*
428 * Send modem control with 'Data Terminal Ready', 'Request To Send' and
429 * 'Output Line 2' message. This enables mouse to identify.
430 */
431 WRITE_PORT_UCHAR(Port + 4, 0x0b);
432
433 /* Wait 10 milliseconds for the mouse getting ready */
435
436 /* Read first four bytes, which contains Microsoft Mouse signs */
437 TimeOut = 20;
438 for (i = 0; i < 4; i++)
439 {
440 while ((READ_PORT_UCHAR(Port + 5) & 1) == 0)
441 {
443 --TimeOut;
444 if (TimeOut == 0)
445 return MOUSE_TYPE_NONE;
446 }
448 }
449
450 TRACE("Mouse data: %x %x %x %x\n",
451 Buffer[0], Buffer[1], Buffer[2], Buffer[3]);
452
453 /* Check that four bytes for signs */
454 for (i = 0; i < 4; ++i)
455 {
456 if (Buffer[i] == 'B')
457 {
458 /* Sign for Microsoft Ballpoint */
459// DbgPrint("Microsoft Ballpoint device detected\n");
460// DbgPrint("THIS DEVICE IS NOT SUPPORTED, YET\n");
461 return MOUSE_TYPE_NONE;
462 }
463 else if (Buffer[i] == 'M')
464 {
465 /* Sign for Microsoft Mouse protocol followed by button specifier */
466 if (i == 3)
467 {
468 /* Overflow Error */
469 return MOUSE_TYPE_NONE;
470 }
471
472 switch (Buffer[i + 1])
473 {
474 case '3':
475 TRACE("Microsoft Mouse with 3-buttons detected\n");
476 return MOUSE_TYPE_LOGITECH;
477
478 case 'Z':
479 TRACE("Microsoft Wheel Mouse detected\n");
480 return MOUSE_TYPE_WHEELZ;
481
482 /* case '2': */
483 default:
484 TRACE("Microsoft Mouse with 2-buttons detected\n");
486 }
487 }
488 }
489
490 return MOUSE_TYPE_NONE;
491}
492
493static ULONG
495{
496 ULONG TimeOut;
497 ULONG i = 0;
498 char c;
499 char x;
500
501 WRITE_PORT_UCHAR(Port + 4, 0x09);
502
503 /* Wait 10 milliseconds for the mouse getting ready */
505
506 WRITE_PORT_UCHAR(Port + 4, 0x0b);
507
509
510 for (;;)
511 {
512 TimeOut = 200;
513 while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
514 {
516 --TimeOut;
517 if (TimeOut == 0)
518 {
519 return 0;
520 }
521 }
522
524 if (c == 0x08 || c == 0x28)
525 break;
526 }
527
528 Buffer[i++] = c;
529 x = c + 1;
530
531 for (;;)
532 {
533 TimeOut = 200;
534 while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
535 {
537 --TimeOut;
538 if (TimeOut == 0)
539 return 0;
540 }
542 Buffer[i++] = c;
543 if (c == x)
544 break;
545 if (i >= 256)
546 break;
547 }
548
549 return i;
550}
551
552static
553VOID
555 PUCHAR Base)
556{
557 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
558 char Buffer[256];
559 CHAR Identifier[256];
560 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
561 ULONG MouseType;
563 ULONG i;
564 ULONG j;
565 ULONG k;
566
567 TRACE("DetectSerialPointerPeripheral()\n");
568
569 Identifier[0] = 0;
570
572 MouseType = DetectSerialMouse(Base);
573
574 if (MouseType != MOUSE_TYPE_NONE)
575 {
577 TRACE( "PnP ID length: %u\n", Length);
578
579 if (Length != 0)
580 {
581 /* Convert PnP sting to ASCII */
582 if (Buffer[0] == 0x08)
583 {
584 for (i = 0; i < Length; i++)
585 Buffer[i] += 0x20;
586 }
587 Buffer[Length] = 0;
588
589 TRACE("PnP ID string: %s\n", Buffer);
590
591 /* Copy PnpId string */
592 for (i = 0; i < 7; i++)
593 {
594 Identifier[i] = Buffer[3 + i];
595 }
596 memcpy(&Identifier[7],
597 L" - ",
598 3 * sizeof(WCHAR));
599
600 /* Skip device serial number */
601 i = 10;
602 if (Buffer[i] == '\\')
603 {
604 for (j = ++i; i < Length; ++i)
605 {
606 if (Buffer[i] == '\\')
607 break;
608 }
609 if (i >= Length)
610 i -= 3;
611 }
612
613 /* Skip PnP class */
614 if (Buffer[i] == '\\')
615 {
616 for (j = ++i; i < Length; ++i)
617 {
618 if (Buffer[i] == '\\')
619 break;
620 }
621
622 if (i >= Length)
623 i -= 3;
624 }
625
626 /* Skip compatible PnP Id */
627 if (Buffer[i] == '\\')
628 {
629 for (j = ++i; i < Length; ++i)
630 {
631 if (Buffer[i] == '\\')
632 break;
633 }
634 if (Buffer[j] == '*')
635 ++j;
636 if (i >= Length)
637 i -= 3;
638 }
639
640 /* Get product description */
641 if (Buffer[i] == '\\')
642 {
643 for (j = ++i; i < Length; ++i)
644 {
645 if (Buffer[i] == ';')
646 break;
647 }
648 if (i >= Length)
649 i -= 3;
650 if (i > j + 1)
651 {
652 for (k = 0; k < i - j; k++)
653 {
654 Identifier[k + 10] = Buffer[k + j];
655 }
656 Identifier[10 + (i - j)] = 0;
657 }
658 }
659
660 TRACE("Identifier string: %s\n", Identifier);
661 }
662
663 if (Length == 0 || strlen(Identifier) < 11)
664 {
665 switch (MouseType)
666 {
668 strcpy(Identifier, "LOGITECH SERIAL MOUSE");
669 break;
670
672 strcpy(Identifier, "MICROSOFT SERIAL MOUSE WITH WHEEL");
673 break;
674
676 default:
677 strcpy(Identifier, "MICROSOFT SERIAL MOUSE");
678 break;
679 }
680 }
681
682 /* Set 'Configuration Data' value */
683 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors);
684 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
685 if (PartialResourceList == NULL)
686 {
687 ERR("Failed to allocate resource descriptor\n");
688 return;
689 }
690
691 RtlZeroMemory(PartialResourceList, Size);
692 PartialResourceList->Version = 1;
693 PartialResourceList->Revision = 1;
694 PartialResourceList->Count = 0;
695
696 /* Create 'PointerPeripheral' key */
697 FldrCreateComponentKey(ControllerKey,
700 Input,
701 0,
702 0xFFFFFFFF,
704 PartialResourceList,
705 Size,
706 &PeripheralKey);
707 }
708}
709
710/* FIXME: Abstract things better so we don't need to place define here */
711#if !defined(SARCH_XBOX)
712static
713ULONG
715{
716 static const ULONG PcIrq[MAX_COM_PORTS] = {4, 3, 4, 3};
717 PUSHORT BasePtr;
718
719 /*
720 * The BIOS data area 0x400 holds the address of the first valid COM port.
721 * Each COM port address is stored in a 2-byte field.
722 * Infos at: https://web.archive.org/web/20240119203029/http://www.bioscentral.com/misc/bda.htm
723 */
724 BasePtr = (PUSHORT)0x400;
725 *Irq = PcIrq[Index];
726
727 return (ULONG) *(BasePtr + Index);
728}
729#endif // !SARCH_XBOX
730
731/*
732 * Parse the serial mouse detection options.
733 * Format: /FASTDETECT
734 * or: /NOSERIALMICE=COM[0-9],[0-9],[0-9]...
735 * or: /NOSERIALMICE:COM[0-9]...
736 * If we have /FASTDETECT, then nothing can be detected.
737 */
738static
739ULONG
742{
743 PCSTR Option, c;
744 ULONG OptionLength, PortBitmap, i;
745
746 if (NtLdrGetOption(Options, "FASTDETECT"))
747 return (1 << MAX_COM_PORTS) - 1;
748
749 Option = NtLdrGetOptionEx(Options, "NOSERIALMICE=", &OptionLength);
750 if (!Option)
751 Option = NtLdrGetOptionEx(Options, "NOSERIALMICE:", &OptionLength);
752
753 if (!Option)
754 return 0;
755
756 /* Invalid port list */
757 if (OptionLength < (sizeof("NOSERIALMICE=COM9") - 1))
758 return (1 << MAX_COM_PORTS) - 1;
759
760 /* Move to the port list */
761 Option += sizeof("NOSERIALMICE=COM") - 1;
762 OptionLength -= sizeof("NOSERIALMICE=COM") - 1;
763
764 PortBitmap = 0;
765 c = Option;
766 for (i = 0; i < OptionLength; i += 2)
767 {
768 UCHAR PortNumber = *c - '0';
769
770 if (PortNumber > 0 && PortNumber <= 9)
771 PortBitmap |= 1 << (PortNumber - 1);
772
773 c += 2;
774 }
775
776 return PortBitmap;
777}
778
779VOID
783 _In_ GET_SERIAL_PORT MachGetSerialPort,
785{
786 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
787 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
788 PCM_SERIAL_DEVICE_DATA SerialDeviceData;
789 ULONG Irq;
790 ULONG Base;
791 CHAR Identifier[80];
792 ULONG ControllerNumber = 0;
793 PCONFIGURATION_COMPONENT_DATA ControllerKey;
794 ULONG i;
795 ULONG Size;
796 ULONG PortBitmap;
797
798 TRACE("DetectSerialPorts()\n");
799
801
802 for (i = 0; i < Count; i++)
803 {
804 Base = MachGetSerialPort(i, &Irq);
805 if ((Base == 0) || !CpDoesPortExist(UlongToPtr(Base)))
806 continue;
807
808 TRACE("Found COM%u port at 0x%x\n", i + 1, Base);
809
810 /* Set 'Identifier' value */
811 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "COM%ld", i + 1);
812
813 /* Build full device descriptor */
814 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[3]) + sizeof(*SerialDeviceData);
815 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
816 if (PartialResourceList == NULL)
817 {
818 ERR("Failed to allocate resource descriptor! Ignoring remaining serial ports. (i = %lu, Count = %lu)\n",
819 i, Count);
820 break;
821 }
822
823 /* Initialize resource descriptor */
824 RtlZeroMemory(PartialResourceList, Size);
825 PartialResourceList->Version = 1;
826 PartialResourceList->Revision = 1;
827 PartialResourceList->Count = 3;
828
829 /* Set IO Port */
830 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
831 PartialDescriptor->Type = CmResourceTypePort;
833 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
834 PartialDescriptor->u.Port.Start.LowPart = Base;
835 PartialDescriptor->u.Port.Start.HighPart = 0x0;
836 PartialDescriptor->u.Port.Length = 8;
837
838 /* Set Interrupt */
839 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
840 PartialDescriptor->Type = CmResourceTypeInterrupt;
842 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
843 PartialDescriptor->u.Interrupt.Level = Irq;
844 PartialDescriptor->u.Interrupt.Vector = Irq;
845 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
846
847 /* Set serial data (device specific) */
848 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
849 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
851 PartialDescriptor->Flags = 0;
852 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(*SerialDeviceData);
853
854 SerialDeviceData = (PCM_SERIAL_DEVICE_DATA)(PartialDescriptor + 1);
855 SerialDeviceData->BaudClock = 1843200; /* UART Clock frequency (Hertz) */
856
857 /* Create controller key */
862 ControllerNumber,
863 0xFFFFFFFF,
865 PartialResourceList,
866 Size,
867 &ControllerKey);
868
869 if (!(PortBitmap & (1 << i)) && !Rs232PortInUse(UlongToPtr(Base)))
870 {
871 /* Detect serial mouse */
873 }
874
875 ControllerNumber++;
876 }
877}
878
879/* FIXME: Abstract things better so we don't need to place define here */
880#if !defined(SARCH_XBOX)
881
882static VOID
884{
885 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
886 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
887 ULONG Irq[MAX_LPT_PORTS] = {7, 5, (ULONG)-1};
888 CHAR Identifier[80];
889 PCONFIGURATION_COMPONENT_DATA ControllerKey;
890 PUSHORT BasePtr;
891 ULONG Base;
892 ULONG ControllerNumber = 0;
893 ULONG i;
894 ULONG Size;
895
896 TRACE("DetectParallelPorts() called\n");
897
898 /*
899 * The BIOS data area 0x408 holds the address of the first valid LPT port.
900 * Each LPT port address is stored in a 2-byte field.
901 * Infos at: https://web.archive.org/web/20240119203029/http://www.bioscentral.com/misc/bda.htm
902 */
903 BasePtr = (PUSHORT)0x408;
904
905 for (i = 0; i < MAX_LPT_PORTS; i++, BasePtr++)
906 {
907 Base = (ULONG) * BasePtr;
908 if (Base == 0)
909 continue;
910
911 TRACE("Parallel port %u: %x\n", ControllerNumber, Base);
912
913 /* Set 'Identifier' value */
914 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "PARALLEL%ld", i + 1);
915
916 /* Build full device descriptor */
917 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]);
918 if (Irq[i] != (ULONG)-1)
920
921 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
922 if (PartialResourceList == NULL)
923 {
924 ERR("Failed to allocate resource descriptor! Ignoring remaining parallel ports. (i = %lu)\n", i);
925 break;
926 }
927
928 /* Initialize resource descriptor */
929 RtlZeroMemory(PartialResourceList, Size);
930 PartialResourceList->Version = 1;
931 PartialResourceList->Revision = 1;
932 PartialResourceList->Count = (Irq[i] != (ULONG)-1) ? 2 : 1;
933
934 /* Set IO Port */
935 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
936 PartialDescriptor->Type = CmResourceTypePort;
938 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
939 PartialDescriptor->u.Port.Start.LowPart = Base;
940 PartialDescriptor->u.Port.Start.HighPart = 0x0;
941 PartialDescriptor->u.Port.Length = 3;
942
943 /* Set Interrupt */
944 if (Irq[i] != (ULONG)-1)
945 {
946 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
947 PartialDescriptor->Type = CmResourceTypeInterrupt;
949 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
950 PartialDescriptor->u.Interrupt.Level = Irq[i];
951 PartialDescriptor->u.Interrupt.Vector = Irq[i];
952 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
953 }
954
955 /* Create controller key */
959 Output,
960 ControllerNumber,
961 0xFFFFFFFF,
963 PartialResourceList,
964 Size,
965 &ControllerKey);
966
967 ControllerNumber++;
968 }
969
970 TRACE("DetectParallelPorts() done\n");
971}
972
973// static
976{
978 UCHAR Scancode;
979 ULONG Loops;
981
982 /* Identify device */
984
985 /* Wait for reply */
986 for (Loops = 0; Loops < 100; Loops++)
987 {
991 break;
992 }
993
995 {
996 /* PC/XT keyboard or no keyboard */
997 Result = FALSE;
998 }
999
1001 if (Scancode != 0xFA)
1002 {
1003 /* No ACK received */
1004 Result = FALSE;
1005 }
1006
1008
1011 {
1012 /* Found AT keyboard */
1013 return Result;
1014 }
1015
1017 if (Scancode != 0xAB)
1018 {
1019 /* No 0xAB received */
1020 Result = FALSE;
1021 }
1022
1024
1027 {
1028 /* No byte in buffer */
1029 Result = FALSE;
1030 }
1031
1033 if (Scancode != 0x41)
1034 {
1035 /* No 0x41 received */
1036 Result = FALSE;
1037 }
1038
1039 /* Found MF-II keyboard */
1040 return Result;
1041}
1042
1043static VOID
1045{
1046 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1047 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
1048 PCM_KEYBOARD_DEVICE_DATA KeyboardData;
1049 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
1050 ULONG Size;
1051 REGS Regs;
1052
1053 /* HACK: don't call DetectKeyboardDevice() as it fails in Qemu 0.8.2
1054 if (DetectKeyboardDevice()) */
1055 {
1056 /* Set 'Configuration Data' value */
1057 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]) + sizeof(*KeyboardData);
1058 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1059 if (PartialResourceList == NULL)
1060 {
1061 ERR("Failed to allocate resource descriptor\n");
1062 return;
1063 }
1064
1065 /* Initialize resource descriptor */
1066 RtlZeroMemory(PartialResourceList, Size);
1067 PartialResourceList->Version = 1;
1068 PartialResourceList->Revision = 1;
1069 PartialResourceList->Count = 1;
1070
1071 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1072 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
1073 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1074 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(*KeyboardData);
1075
1076 /* Int 16h AH=02h
1077 * KEYBOARD - GET SHIFT FLAGS
1078 *
1079 * Return:
1080 * AL - shift flags
1081 */
1082 Regs.b.ah = 0x02;
1083 Int386(0x16, &Regs, &Regs);
1084
1085 KeyboardData = (PCM_KEYBOARD_DEVICE_DATA)(PartialDescriptor + 1);
1086 KeyboardData->Version = 1;
1087 KeyboardData->Revision = 1;
1088 KeyboardData->Type = 4;
1089 KeyboardData->Subtype = 0;
1090 KeyboardData->KeyboardFlags = Regs.b.al;
1091
1092 /* Create controller key */
1093 FldrCreateComponentKey(ControllerKey,
1096 Input | ConsoleIn,
1097 0,
1098 0xFFFFFFFF,
1099 "PCAT_ENHANCED",
1100 PartialResourceList,
1101 Size,
1102 &PeripheralKey);
1103 }
1104}
1105
1106static
1107VOID
1109{
1110 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1111 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
1112 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1113 ULONG Size;
1114
1115 /* Set 'Configuration Data' value */
1116 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[3]);
1117 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1118 if (PartialResourceList == NULL)
1119 {
1120 ERR("Failed to allocate resource descriptor\n");
1121 return;
1122 }
1123
1124 /* Initialize resource descriptor */
1125 RtlZeroMemory(PartialResourceList, Size);
1126 PartialResourceList->Version = 1;
1127 PartialResourceList->Revision = 1;
1128 PartialResourceList->Count = 3;
1129
1130 /* Set Interrupt */
1131 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1132 PartialDescriptor->Type = CmResourceTypeInterrupt;
1133 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1134 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1135 PartialDescriptor->u.Interrupt.Level = 1;
1136 PartialDescriptor->u.Interrupt.Vector = 1;
1137 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
1138
1139 /* Set IO Port 0x60 */
1140 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
1141 PartialDescriptor->Type = CmResourceTypePort;
1143 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1144 PartialDescriptor->u.Port.Start.LowPart = 0x60;
1145 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1146 PartialDescriptor->u.Port.Length = 1;
1147
1148 /* Set IO Port 0x64 */
1149 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
1150 PartialDescriptor->Type = CmResourceTypePort;
1152 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1153 PartialDescriptor->u.Port.Start.LowPart = 0x64;
1154 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1155 PartialDescriptor->u.Port.Length = 1;
1156
1157 /* Create controller key */
1161 Input | ConsoleIn,
1162 0,
1163 0xFFFFFFFF,
1164 NULL,
1165 PartialResourceList,
1166 Size,
1167 &ControllerKey);
1168
1169 DetectKeyboardPeripheral(ControllerKey);
1170}
1171
1172static
1173VOID
1175{
1176 ULONG Timeout;
1177 UCHAR Status;
1178
1180 {
1183 return;
1184
1185 /* Sleep for one millisecond */
1187 }
1188}
1189
1190static
1191BOOLEAN
1193{
1194#if 1
1195 /* Current detection is too unreliable. Just do as if
1196 * the PS/2 aux port is always present
1197 */
1198 return TRUE;
1199#else
1200 ULONG Loops;
1201 UCHAR Status;
1202
1203 /* Put the value 0x5A in the output buffer using the
1204 * "WriteAuxiliary Device Output Buffer" command (0xD3).
1205 * Poll the Status Register for a while to see if the value really turns up
1206 * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1207 * to 1 in the Status Register, we assume this controller has an
1208 * Auxiliary Port (a.k.a. Mouse Port).
1209 */
1214
1215 /* 0x5A is a random dummy value */
1217 0x5A);
1218
1219 for (Loops = 0; Loops < 10; Loops++)
1220 {
1224 break;
1225 }
1226
1228
1230#endif
1231}
1232
1233static
1234BOOLEAN
1236{
1237 UCHAR Scancode;
1238 UCHAR Status;
1239 ULONG Loops;
1241
1246
1247 /* Identify device */
1249
1250 /* Wait for reply */
1251 for (Loops = 0; Loops < 100; Loops++)
1252 {
1256 break;
1257 }
1258
1261 Result = FALSE;
1262
1264 if (Scancode != 0xFA)
1265 Result = FALSE;
1266
1268
1271 Result = FALSE;
1272
1274 if (Scancode != 0x00)
1275 Result = FALSE;
1276
1277 return Result;
1278}
1279
1280// FIXME: Missing: DetectPS2Peripheral!! (for corresponding 'PointerPeripheral')
1281
1282static
1283VOID
1285{
1286 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1287 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1288 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
1289 ULONG Size;
1290
1291 if (DetectPS2AuxPort())
1292 {
1293 TRACE("Detected PS2 port\n");
1294
1295 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]);
1296 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1297 if (PartialResourceList == NULL)
1298 {
1299 ERR("Failed to allocate resource descriptor\n");
1300 return;
1301 }
1302
1303 /* Initialize resource descriptor */
1304 RtlZeroMemory(PartialResourceList, Size);
1305 PartialResourceList->Version = 1;
1306 PartialResourceList->Revision = 1;
1307 PartialResourceList->Count = 1;
1308
1309 /* Set Interrupt */
1310 PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeInterrupt;
1312 PartialResourceList->PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1313 PartialResourceList->PartialDescriptors[0].u.Interrupt.Level = 12;
1314 PartialResourceList->PartialDescriptors[0].u.Interrupt.Vector = 12;
1315 PartialResourceList->PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF;
1316
1317 /* Create controller key */
1321 Input,
1322 0,
1323 0xFFFFFFFF,
1324 NULL,
1325 PartialResourceList,
1326 Size,
1327 &ControllerKey);
1328
1329 if (DetectPS2AuxDevice())
1330 {
1331 TRACE("Detected PS2 mouse\n");
1332
1333 /* Initialize resource descriptor */
1334 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors);
1335 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1336 if (PartialResourceList == NULL)
1337 {
1338 ERR("Failed to allocate resource descriptor\n");
1339 return;
1340 }
1341
1342 RtlZeroMemory(PartialResourceList, Size);
1343 PartialResourceList->Version = 1;
1344 PartialResourceList->Revision = 1;
1345 PartialResourceList->Count = 0;
1346
1347 /* Create peripheral key */
1348 FldrCreateComponentKey(ControllerKey,
1351 Input,
1352 0,
1353 0xFFFFFFFF,
1354 "MICROSOFT PS2 MOUSE",
1355 PartialResourceList,
1356 Size,
1357 &PeripheralKey);
1358 }
1359 }
1360}
1361
1362#if defined(_M_IX86)
1363static VOID
1364CreateBusMousePeripheralKey(
1366 _In_ ULONG IoBase,
1367 _In_ ULONG Irq)
1368{
1369 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1370 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
1371 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1372 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
1373 ULONG Size;
1374
1375 /* Set 'Configuration Data' value */
1376 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[2]);
1377 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1378 if (PartialResourceList == NULL)
1379 {
1380 ERR("Failed to allocate resource descriptor\n");
1381 return;
1382 }
1383
1384 /* Initialize resource descriptor */
1385 RtlZeroMemory(PartialResourceList, Size);
1386 PartialResourceList->Version = 1;
1387 PartialResourceList->Revision = 1;
1388 PartialResourceList->Count = 2;
1389
1390 /* Set IO Port */
1391 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1392 PartialDescriptor->Type = CmResourceTypePort;
1394 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1395 PartialDescriptor->u.Port.Start.LowPart = IoBase;
1396 PartialDescriptor->u.Port.Start.HighPart = 0;
1397 PartialDescriptor->u.Port.Length = 4;
1398
1399 /* Set Interrupt */
1400 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
1401 PartialDescriptor->Type = CmResourceTypeInterrupt;
1402 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1403 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1404 PartialDescriptor->u.Interrupt.Level = Irq;
1405 PartialDescriptor->u.Interrupt.Vector = Irq;
1406 PartialDescriptor->u.Interrupt.Affinity = (KAFFINITY)-1;
1407
1408 /* Create controller key */
1412 Input,
1413 0,
1414 0xFFFFFFFF,
1415 NULL,
1416 PartialResourceList,
1417 Size,
1418 &ControllerKey);
1419
1420 /* Set 'Configuration Data' value */
1421 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors);
1422 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1423 if (PartialResourceList == NULL)
1424 {
1425 ERR("Failed to allocate resource descriptor\n");
1426 return;
1427 }
1428
1429 /* Initialize resource descriptor */
1430 RtlZeroMemory(PartialResourceList, Size);
1431 PartialResourceList->Version = 1;
1432 PartialResourceList->Revision = 1;
1433 PartialResourceList->Count = 0;
1434
1435 /* Create peripheral key */
1436 FldrCreateComponentKey(ControllerKey,
1439 Input,
1440 0,
1441 0xFFFFFFFF,
1442 "MICROSOFT INPORT MOUSE",
1443 PartialResourceList,
1444 Size,
1445 &PeripheralKey);
1446}
1447
1448extern KIDTENTRY DECLSPEC_ALIGN(4) i386Idt[32];
1449VOID __cdecl HwIrqHandler(VOID);
1450extern volatile ULONG HwIrqCount;
1451
1452static ULONG
1453DetectBusMouseTestIrq(
1454 _In_ ULONG IoBase,
1455 _In_ ULONG Irq)
1456{
1457 USHORT OldOffset, OldExtendedOffset;
1458 ULONG Vector, i;
1459
1460 HwIrqCount = 0;
1461
1462 /* Reset the device */
1465
1466 Vector = Irq + 8;
1467
1468 /* Save the old interrupt vector and replace it by ours */
1469 OldOffset = i386Idt[Vector].Offset;
1470 OldExtendedOffset = i386Idt[Vector].ExtendedOffset;
1471
1472 i386Idt[Vector].Offset = (ULONG)HwIrqHandler & 0xFFFF;
1473 i386Idt[Vector].ExtendedOffset = (ULONG)HwIrqHandler >> 16;
1474
1475 /* Enable the requested IRQ on the master PIC */
1476 WRITE_PORT_UCHAR((PUCHAR)PIC1_DATA_PORT, ~(1 << Irq));
1477
1478 _enable();
1479
1480 /* Configure the device to generate interrupts */
1481 for (i = 0; i < 15; i++)
1482 {
1485 }
1486
1487 /* Disable the device */
1489
1490 _disable();
1491
1492 i386Idt[Vector].Offset = OldOffset;
1493 i386Idt[Vector].ExtendedOffset = OldExtendedOffset;
1494
1495 return (HwIrqCount != 0) ? Irq : 0;
1496}
1497
1498static ULONG
1499DetectBusMouseIrq(
1500 _In_ ULONG IoBase)
1501{
1502 UCHAR Mask1, Mask2;
1503 ULONG Irq, Result;
1504
1505 /* Save the current interrupt mask */
1508
1509 /* Mask the interrupts on the slave PIC */
1511
1512 /* Process IRQ detection: IRQ 5, 4, 3 */
1513 for (Irq = 5; Irq >= 3; Irq--)
1514 {
1515 Result = DetectBusMouseTestIrq(IoBase, Irq);
1516 if (Result != 0)
1517 break;
1518 }
1519
1520 /* Restore the mask */
1523
1524 return Result;
1525}
1526
1527static VOID
1528DetectBusMouse(
1530{
1531 ULONG IoBase, Irq, Signature1, Signature2, Signature3;
1532
1533 /*
1534 * The bus mouse lives at one of these addresses: 0x230, 0x234, 0x238, 0x23C.
1535 * The 0x23C port is the most common I/O setting.
1536 */
1537 for (IoBase = 0x23C; IoBase >= 0x230; IoBase -= 4)
1538 {
1539 Signature1 = READ_PORT_UCHAR((PUCHAR)IoBase + INPORT_REGISTER_SIGNATURE);
1540 Signature2 = READ_PORT_UCHAR((PUCHAR)IoBase + INPORT_REGISTER_SIGNATURE);
1541 if (Signature1 == Signature2)
1542 continue;
1543 if (Signature1 != INPORT_SIGNATURE && Signature2 != INPORT_SIGNATURE)
1544 continue;
1545
1546 Signature3 = READ_PORT_UCHAR((PUCHAR)IoBase + INPORT_REGISTER_SIGNATURE);
1547 if (Signature1 != Signature3)
1548 continue;
1549
1550 Irq = DetectBusMouseIrq(IoBase);
1551 if (Irq == 0)
1552 continue;
1553
1554 CreateBusMousePeripheralKey(BusKey, IoBase, Irq);
1555 break;
1556 }
1557}
1558#endif /* _M_IX86 */
1559
1560// Implemented in pcvesa.c, returns the VESA version
1564
1565static VOID
1567{
1569 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1570 USHORT VesaVersion;
1571
1572 /* FIXME: Set 'ComponentInformation' value */
1573
1574 VesaVersion = BiosIsVesaSupported();
1575 if (VesaVersion != 0)
1576 {
1577 TRACE("VESA version %c.%c\n",
1578 (VesaVersion >> 8) + '0',
1579 (VesaVersion & 0xFF) + '0');
1580 }
1581 else
1582 {
1583 TRACE("VESA not supported\n");
1584 }
1585
1586 if (VesaVersion >= 0x0200)
1587 Identifier = "VBE Display";
1588 else
1589 Identifier = "VGA Display";
1590
1595 0,
1596 0xFFFFFFFF,
1597 Identifier,
1598 NULL,
1599 0,
1600 &ControllerKey);
1601
1602 /* FIXME: Add display peripheral (monitor) data */
1603 if (VesaVersion != 0)
1604 {
1606 {
1607 TRACE("VESA/DDC supported!\n");
1608 if (BiosVesaReadEdid())
1609 {
1610 TRACE("EDID data read successfully!\n");
1611 }
1612 }
1613 }
1614}
1615
1616static
1617VOID
1622{
1623 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1625 ULONG Size;
1626
1627 /* Set 'Configuration Data' value */
1628 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors);
1629 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1630 if (PartialResourceList == NULL)
1631 {
1632 ERR("Failed to allocate resource descriptor\n");
1633 return;
1634 }
1635
1636 /* Initialize resource descriptor */
1637 RtlZeroMemory(PartialResourceList, Size);
1638 PartialResourceList->Version = 1;
1639 PartialResourceList->Revision = 1;
1640 PartialResourceList->Count = 0;
1641
1642 /* Create new bus key */
1643 FldrCreateComponentKey(SystemKey,
1646 0,
1647 0,
1648 0xFFFFFFFF,
1649 "ISA",
1650 PartialResourceList,
1651 Size,
1652 &BusKey);
1653
1654 /* Increment bus number */
1655 (*BusNumber)++;
1656
1657 /* Detect ISA/BIOS devices */
1658 DetectBiosDisks(SystemKey, BusKey);
1660 DetectParallelPorts(BusKey);
1662 DetectPS2Mouse(BusKey);
1663#if defined(_M_IX86)
1664 DetectBusMouse(BusKey);
1665#endif
1667
1668 /* FIXME: Detect more ISA devices */
1669}
1670
1671static
1672UCHAR
1674{
1675 UCHAR Data;
1676
1677 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
1678 Data = READ_PORT_UCHAR((PUCHAR)0x71);
1679
1680 return ((Data & 0xF0) ? 1 : 0) + ((Data & 0x0F) ? 1 : 0);
1681}
1682
1686{
1688 ULONG BusNumber = 0;
1689
1690 TRACE("DetectHardware()\n");
1691
1692 /* Create the 'System' key */
1693 // TODO: Discover and set the other machine types
1694 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
1695
1698
1699 /* Detect buses */
1700 DetectPciBios(SystemKey, &BusNumber);
1701 DetectApmBios(SystemKey, &BusNumber);
1702 DetectPnpBios(SystemKey, &BusNumber);
1703 DetectIsaBios(Options, SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
1704 DetectAcpiBios(SystemKey, &BusNumber);
1705
1706 // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
1707 // CM_ROM_BLOCK data into the 'System' key's configuration data.
1708
1709 TRACE("DetectHardware() Done\n");
1710 return SystemKey;
1711}
1712
1713VOID
1715{
1716 REGS Regs;
1717
1718 /* Select APM 1.0+ function */
1719 Regs.b.ah = 0x53;
1720
1721 /* Function 05h: CPU idle */
1722 Regs.b.al = 0x05;
1723
1724 /* Call INT 15h */
1725 Int386(0x15, &Regs, &Regs);
1726
1727 /* Check if successfull (CF set on error) */
1728 if (INT386_SUCCESS(Regs))
1729 return;
1730
1731 /*
1732 * No futher processing here.
1733 * Optionally implement HLT instruction handling.
1734 */
1735}
1736
1738 IN UCHAR BootDrive OPTIONAL,
1739 IN ULONG BootPartition OPTIONAL)
1740{
1741 REGS Regs;
1742
1743 RtlZeroMemory(&Regs, sizeof(Regs));
1744
1745 /* Set the boot drive and the boot partition */
1746 Regs.b.dl = (UCHAR)(BootDrive ? BootDrive : FrldrBootDrive);
1747 Regs.b.dh = (UCHAR)(BootPartition ? BootPartition : FrldrBootPartition);
1748
1749 /*
1750 * Don't stop the floppy drive motor when we are just booting a bootsector,
1751 * a drive, or a partition. If we were to stop the floppy motor, the BIOS
1752 * wouldn't be informed and if the next read is to a floppy then the BIOS
1753 * will still think the motor is on and this will result in a read error.
1754 */
1755 // DiskStopFloppyMotor();
1756
1757 Relocator16Boot(&Regs,
1758 /* Stack segment:pointer */
1759 0x0000, 0x7C00,
1760 /* Code segment:pointer */
1761 0x0000, 0x7C00);
1762}
1763
1764#endif // !SARCH_XBOX
1765
1766
1767/******************************************************************************/
1768
1769/* FIXME: Abstract things better so we don't need to place define here */
1770#if !defined(SARCH_XBOX)
1771VOID
1772MachInit(const char *CmdLine)
1773{
1774 /* Setup vtbl */
1775 RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
1804
1806 PcVideoInit();
1807}
1808
1809VOID
1811{
1812 /* Prepare video and turn off the floppy motor */
1815}
1816#endif
1817
1818/* EOF */
@ DeviceNode
Definition: Node.h:9
unsigned char BOOLEAN
Definition: actypes.h:127
MACHVTBL MachVtbl
Definition: arcemul.c:21
#define ExtendedBIOSDataArea
Definition: winldr.c:346
#define ExtendedBIOSDataSize
Definition: winldr.c:347
VOID FldrCreateSystemKey(_Out_ PCONFIGURATION_COMPONENT_DATA *SystemNode, _In_ PCSTR IdentifierString)
Definition: archwsup.c:135
VOID FldrCreateComponentKey(_In_ PCONFIGURATION_COMPONENT_DATA SystemNode, _In_ CONFIGURATION_CLASS Class, _In_ CONFIGURATION_TYPE Type, _In_ IDENTIFIER_FLAG Flags, _In_ ULONG Key, _In_ ULONG Affinity, _In_ PCSTR IdentifierString, _In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _In_ ULONG Size, _Out_ PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:198
@ Identifier
Definition: asmpp.cpp:95
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwacpi.c:59
VOID DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwpci.c:174
BOOLEAN PcFindPciBios(PPCI_REGISTRY_INFO BusData)
Definition: hwpci.c:80
FIND_PCI_BIOS FindPciBios
Definition: hwpci.c:26
#define DiskReadBuffer
Definition: hardware.h:33
ULONG __cdecl PnpBiosGetDeviceNode(UCHAR *NodeId, UCHAR *NodeBuffer)
ULONG __cdecl PnpBiosGetDeviceNodeCount(ULONG *NodeSize, ULONG *NodeCount)
ULONG_PTR __cdecl PnpBiosSupported(VOID)
ULONG(* GET_SERIAL_PORT)(ULONG Index, PULONG Irq)
Definition: hardware.h:80
ULONG __cdecl PnpBiosGetDockStationInformation(UCHAR *DockingStationInfo)
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: heap.c:539
PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: heap.c:533
Definition: bufpool.h:45
BOOLEAN Rs232PortInUse(PUCHAR Base)
Definition: rs232.c:140
BOOLEAN NTAPI CpDoesPortExist(IN PUCHAR Address)
Definition: cport.c:224
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define DECLSPEC_ALIGN(x)
Definition: corecrt.h:141
#define __cdecl
Definition: corecrt.h:121
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Definition: string.c:3330
static const WCHAR CmdLine[]
Definition: install.c:48
#define L(x)
Definition: resources.c:13
#define UlongToPtr(u)
Definition: config.h:106
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:25
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLubyte * c
Definition: glext.h:8905
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
CPPORT Port[4]
Definition: headless.c:35
VOID DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwapm.c:46
BOOLEAN PcInitializeBootDevices(VOID)
Definition: hwdisk.c:458
#define c
Definition: ke_i.h:80
if(dx< 0)
Definition: linetemp.h:194
#define CONTROLLER_COMMAND_WRITE_MOUSE
Definition: machpc.c:77
VOID PcGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machpc.c:107
#define PIC1_DATA_PORT
Definition: machpc.c:54
static VOID DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: machpc.c:253
#define MOUSE_TYPE_MICROSOFT
Definition: machpc.c:35
static VOID DetectDockingStation(_Inout_ PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:190
#define MAX_LPT_PORTS
Definition: machpc.c:30
BOOLEAN BiosVesaReadEdid(VOID)
Definition: pcvesa.c:270
static VOID PS2ControllerWait(VOID)
Definition: machpc.c:1174
#define INPORT_REGISTER_DATA
Definition: machpc.c:44
#define INPORT_REGISTER_CONTROL
Definition: machpc.c:43
#define INPORT_MODE_BASE
Definition: machpc.c:49
static ULONG GetSerialMousePnpId(PUCHAR Port, char *Buffer)
Definition: machpc.c:494
static ULONG DetectSerialMouse(PUCHAR Port)
Definition: machpc.c:401
static VOID DetectIsaBios(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA SystemKey, _Out_ ULONG *BusNumber)
Definition: machpc.c:1618
VOID MachInit(const char *CmdLine)
Definition: machpc.c:1772
#define INPORT_TEST_IRQ
Definition: machpc.c:50
static BOOLEAN DetectPS2AuxDevice(VOID)
Definition: machpc.c:1235
#define CONTROLLER_REGISTER_STATUS
Definition: machpc.c:61
#define CONTROLLER_STATUS_INPUT_BUFFER_FULL
Definition: machpc.c:81
#define MOUSE_TYPE_LOGITECH
Definition: machpc.c:37
static ULONG PcGetSerialPort(ULONG Index, PULONG Irq)
Definition: machpc.c:714
BOOLEAN DetectKeyboardDevice(VOID)
Definition: machpc.c:975
#define MAX_COM_PORTS
Definition: machpc.c:29
static UCHAR PcGetFloppyCount(VOID)
Definition: machpc.c:1673
static VOID DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1108
PCONFIGURATION_COMPONENT_DATA PcHwDetect(_In_opt_ PCSTR Options)
Definition: machpc.c:1684
#define PIC2_DATA_PORT
Definition: machpc.c:56
static VOID InitializeSerialPort(PUCHAR Port, UCHAR LineControl)
Definition: machpc.c:387
#define CONTROLLER_TIMEOUT
Definition: machpc.c:92
#define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
Definition: machpc.c:85
struct _PNP_DOCK_INFO * PPNP_DOCK_INFO
VOID PcHwIdle(VOID)
Definition: machpc.c:1714
#define MOUSE_TYPE_NONE
Definition: machpc.c:33
#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL
Definition: machpc.c:80
struct _PNP_DOCK_INFO PNP_DOCK_INFO
#define CONTROLLER_REGISTER_CONTROL
Definition: machpc.c:62
VOID PcPrepareForReactOS(VOID)
Definition: machpc.c:1810
#define MOUSE_TYPE_WHEELZ
Definition: machpc.c:39
VOID __cdecl ChainLoadBiosBootSectorCode(IN UCHAR BootDrive OPTIONAL, IN ULONG BootPartition OPTIONAL)
Definition: machpc.c:1737
#define INPORT_REG_MODE
Definition: machpc.c:47
static BOOLEAN DetectPS2AuxPort(VOID)
Definition: machpc.c:1192
static VOID DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1284
static VOID DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: machpc.c:1044
static ULONG GetSerialMouseDetectionBitmap(_In_opt_ PCSTR Options)
Definition: machpc.c:740
static VOID DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:883
#define INPORT_SIGNATURE
Definition: machpc.c:51
VOID DetectSerialPorts(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA BusKey, _In_ GET_SERIAL_PORT MachGetSerialPort, _In_ ULONG Count)
Definition: machpc.c:780
#define INPORT_REGISTER_SIGNATURE
Definition: machpc.c:45
static VOID DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1566
#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER
Definition: machpc.c:76
#define INPORT_RESET
Definition: machpc.c:48
#define CONTROLLER_REGISTER_DATA
Definition: machpc.c:63
static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: machpc.c:131
static VOID DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey, PUCHAR Base)
Definition: machpc.c:554
BOOLEAN BiosIsVesaDdcSupported(VOID)
Definition: pcvesa.c:241
USHORT BiosIsVesaSupported(VOID)
Definition: pcvesa.c:160
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int k
Definition: mpi.c:3369
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2486
#define _Inout_
Definition: no_sal2.h:162
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
int Count
Definition: noreturn.cpp:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
PCSTR NtLdrGetOption(IN PCSTR Options, IN PCSTR OptionName)
Definition: ntldropts.c:128
PCSTR NtLdrGetOptionEx(IN PCSTR Options, IN PCSTR OptionName, OUT PULONG OptionLength OPTIONAL)
Definition: ntldropts.c:117
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
VOID __cdecl DiskStopFloppyMotor(VOID)
Definition: pc98hw.c:1217
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
VOID PcBeep(VOID)
Definition: pcbeep.c:34
#define INT386_SUCCESS(regs)
Definition: pcbios.h:181
int __cdecl Int386(int ivec, REGS *in, REGS *out)
DECLSPEC_NORETURN VOID __cdecl Relocator16Boot(IN REGS *In, IN USHORT StackSegment, IN USHORT StackPointer, IN USHORT CodeSegment, IN USHORT CodePointer)
struct _DOCKING_STATE_INFORMATION * PDOCKING_STATE_INFORMATION
VOID PcConsPutChar(int Ch)
Definition: pccons.c:22
BOOLEAN PcConsKbHit(VOID)
Definition: pccons.c:63
int PcConsGetCh(void)
Definition: pccons.c:84
BOOLEAN PcDiskReadLogicalSectors(IN UCHAR DriveNumber, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
Definition: pcdisk.c:786
ULONG PcDiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: pcdisk.c:856
BOOLEAN PcDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: pcdisk.c:826
VOID HalpCalibrateStallExecution(VOID)
Definition: pchw.c:105
VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pchw.c:342
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData
Definition: pchw.c:45
VOID StallExecutionProcessor(ULONG Microseconds)
Definition: pchw.c:60
PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap(ULONG *MemoryMapSize)
Definition: pcmem.c:609
TIMEINFO * PcGetTime(VOID)
Definition: pcrtc.c:30
VOID PcVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
Definition: pcvideo.c:1161
VOID PcVideoPrepareForReactOS(VOID)
Definition: pcvideo.c:1308
BOOLEAN PcVideoIsPaletteFixed(VOID)
Definition: pcvideo.c:1261
VOID PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: pcvideo.c:1267
VOID PcVideoSync(VOID)
Definition: pcvideo.c:1285
VOID PcVideoGetFontsFromFirmware(PULONG RomFontPointers)
Definition: pcvideo.c:1127
VOID PcVideoInit(VOID)
Definition: pcvideo.c:1020
VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: pcvideo.c:1097
VOID PcVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: pcvideo.c:1276
VIDEODISPLAYMODE PcVideoSetDisplayMode(PCSTR DisplayModeName, BOOLEAN Init)
Definition: pcvideo.c:1045
ULONG PcVideoGetBufferSize(VOID)
Definition: pcvideo.c:1121
VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: pcvideo.c:1252
VOID PcVideoClearScreen(UCHAR Attr)
Definition: pcvideo.c:1236
VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: pcvideo.c:1195
VOID PcVideoHideShowTextCursor(BOOLEAN Show)
Definition: pcvideo.c:1186
unsigned short USHORT
Definition: pedump.c:61
static ULONG Timeout
Definition: ping.c:61
struct _CM_PNP_BIOS_INSTALLATION_CHECK * PCM_PNP_BIOS_INSTALLATION_CHECK
struct _CM_PNP_BIOS_DEVICE_NODE * PCM_PNP_BIOS_DEVICE_NODE
#define volatile
Definition: prototyp.h:117
#define CmResourceTypeDeviceSpecific
Definition: restypes.h:108
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
#define CmResourceTypePort
Definition: restypes.h:104
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: restypes.h:117
#define CmResourceTypeInterrupt
Definition: restypes.h:105
@ ControllerClass
Definition: arc.h:103
@ AdapterClass
Definition: arc.h:102
@ PeripheralClass
Definition: arc.h:104
@ PointerController
Definition: arc.h:134
@ MultiFunctionAdapter
Definition: arc.h:125
@ SerialController
Definition: arc.h:130
@ ParallelController
Definition: arc.h:133
@ KeyboardPeripheral
Definition: arc.h:145
@ KeyboardController
Definition: arc.h:135
@ DockingInformation
Definition: arc.h:151
@ PointerPeripheral
Definition: arc.h:144
@ DisplayController
Definition: arc.h:132
@ ConsoleOut
Definition: arc.h:92
@ ConsoleIn
Definition: arc.h:91
@ Input
Definition: arc.h:93
@ Output
Definition: arc.h:94
strcpy
Definition: string.h:131
void __cdecl _disable(void)
Definition: intrin_arm.h:365
void __cdecl _enable(void)
Definition: intrin_arm.h:373
#define TRACE(s)
Definition: solgame.cpp:4
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
ULONG PortNumber
Definition: storport.c:18
unsigned char dl
Definition: pcbios.h:142
unsigned char al
Definition: pcbios.h:133
unsigned char ah
Definition: pcbios.h:134
unsigned char dh
Definition: pcbios.h:143
unsigned long eax
Definition: pcbios.h:93
unsigned short es
Definition: pcbios.h:123
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382::@391 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382::@384 Port
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382::@385 Interrupt
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: restypes.h:100
Definition: disk.h:26
ULONG BytesPerSector
Number of bytes per sector.
Definition: disk.h:30
ULONG Cylinders
Number of cylinders on the disk.
Definition: disk.h:27
ULONG SectorsPerTrack
Number of sectors per track.
Definition: disk.h:29
ULONG Heads
Number of heads on the disk.
Definition: disk.h:28
ULONG SerialNumber
Definition: machpc.c:98
ULONG DockLocationID
Definition: machpc.c:97
USHORT Capabilities
Definition: machpc.c:99
VOID(* VideoGetPaletteColor)(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: machine.h:56
VIDEODISPLAYMODE(* VideoSetDisplayMode)(PCSTR DisplayMode, BOOLEAN Init)
Definition: machine.h:46
VOID(* GetExtendedBIOSData)(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machine.h:64
int(* ConsGetCh)(VOID)
Definition: machine.h:43
VOID(* PrepareForReactOS)(VOID)
Definition: machine.h:59
VOID(* VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: machine.h:55
BOOLEAN(* InitializeBootDevices)(VOID)
Definition: machine.h:76
VOID(* VideoCopyOffScreenBufferToVRAM)(PVOID Buffer)
Definition: machine.h:53
BOOLEAN(* ConsKbHit)(VOID)
Definition: machine.h:42
VOID(* VideoHideShowTextCursor)(BOOLEAN Show)
Definition: machine.h:51
TIMEINFO *(* GetTime)(VOID)
Definition: machine.h:72
UCHAR(* GetFloppyCount)(VOID)
Definition: machine.h:66
BOOLEAN(* DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry)
Definition: machine.h:68
BOOLEAN(* DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: machine.h:67
PFREELDR_MEMORY_DESCRIPTOR(* GetMemoryMap)(PULONG MaxMemoryMapSize)
Definition: machine.h:63
VOID(* VideoGetFontsFromFirmware)(PULONG RomFontPointers)
Definition: machine.h:49
VOID(* Beep)(VOID)
Definition: machine.h:58
VOID(* VideoSetTextCursorPosition)(UCHAR X, UCHAR Y)
Definition: machine.h:50
ULONG(* VideoGetBufferSize)(VOID)
Definition: machine.h:48
VOID(* VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: machine.h:52
ULONG(* DiskGetCacheableBlockCount)(UCHAR DriveNumber)
Definition: machine.h:69
VOID(* VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth)
Definition: machine.h:47
VOID(* VideoClearScreen)(UCHAR Attr)
Definition: machine.h:45
VOID(* HwIdle)(VOID)
Definition: machine.h:78
VOID(* VideoSync)(VOID)
Definition: machine.h:57
BOOLEAN(* VideoIsPaletteFixed)(VOID)
Definition: machine.h:54
PCONFIGURATION_COMPONENT_DATA(* HwDetect)(_In_opt_ PCSTR Options)
Definition: machine.h:77
VOID(* ConsPutChar)(int Ch)
Definition: machine.h:41
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint16_t * PUSHORT
Definition: typedefs.h:56
const char * PCSTR
Definition: typedefs.h:52
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define TAG_HW_RESOURCE_LIST
Definition: uefidisk.c:15
UCHAR FrldrBootDrive
Definition: uefidisk.c:104
ULONG FrldrBootPartition
Definition: uefidisk.c:105
Definition: pcbios.h:161
DWORDREGS d
Definition: pcbios.h:163
BYTEREGS b
Definition: pcbios.h:165
WORDREGS w
Definition: pcbios.h:164
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3540
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
struct _CM_SERIAL_DEVICE_DATA * PCM_SERIAL_DEVICE_DATA
struct _CM_KEYBOARD_DEVICE_DATA * PCM_KEYBOARD_DEVICE_DATA
struct _CM_DISK_GEOMETRY_DEVICE_DATA * PCM_DISK_GEOMETRY_DEVICE_DATA
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241
@ CmResourceShareUndetermined
Definition: cmtypes.h:240
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160
_Out_ PUSHORT NodeNumber
Definition: iofuncs.h:2574
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175