ReactOS  0.4.13-dev-544-gede3fdd
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 <debug.h>
23 
24 DBG_DEFAULT_CHANNEL(HWDETECT);
25 
26 
27 /* Maximum number of COM and LPT ports */
28 #define MAX_COM_PORTS 4
29 #define MAX_LPT_PORTS 3
30 
31 /* No Mouse */
32 #define MOUSE_TYPE_NONE 0
33 /* Microsoft Mouse with 2 buttons */
34 #define MOUSE_TYPE_MICROSOFT 1
35 /* Logitech Mouse with 3 buttons */
36 #define MOUSE_TYPE_LOGITECH 2
37 /* Microsoft Wheel Mouse (aka Z Mouse) */
38 #define MOUSE_TYPE_WHEELZ 3
39 /* Mouse Systems Mouse */
40 #define MOUSE_TYPE_MOUSESYSTEMS 4
41 
42 
43 /* PS2 stuff */
44 
45 /* Controller registers. */
46 #define CONTROLLER_REGISTER_STATUS 0x64
47 #define CONTROLLER_REGISTER_CONTROL 0x64
48 #define CONTROLLER_REGISTER_DATA 0x60
49 
50 /* Controller commands. */
51 #define CONTROLLER_COMMAND_READ_MODE 0x20
52 #define CONTROLLER_COMMAND_WRITE_MODE 0x60
53 #define CONTROLLER_COMMAND_GET_VERSION 0xA1
54 #define CONTROLLER_COMMAND_MOUSE_DISABLE 0xA7
55 #define CONTROLLER_COMMAND_MOUSE_ENABLE 0xA8
56 #define CONTROLLER_COMMAND_TEST_MOUSE 0xA9
57 #define CONTROLLER_COMMAND_SELF_TEST 0xAA
58 #define CONTROLLER_COMMAND_KEYBOARD_TEST 0xAB
59 #define CONTROLLER_COMMAND_KEYBOARD_DISABLE 0xAD
60 #define CONTROLLER_COMMAND_KEYBOARD_ENABLE 0xAE
61 #define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER 0xD3
62 #define CONTROLLER_COMMAND_WRITE_MOUSE 0xD4
63 
64 /* Controller status */
65 #define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL 0x01
66 #define CONTROLLER_STATUS_INPUT_BUFFER_FULL 0x02
67 #define CONTROLLER_STATUS_SELF_TEST 0x04
68 #define CONTROLLER_STATUS_COMMAND 0x08
69 #define CONTROLLER_STATUS_UNLOCKED 0x10
70 #define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL 0x20
71 #define CONTROLLER_STATUS_GENERAL_TIMEOUT 0x40
72 #define CONTROLLER_STATUS_PARITY_ERROR 0x80
73 #define AUX_STATUS_OUTPUT_BUFFER_FULL (CONTROLLER_STATUS_OUTPUT_BUFFER_FULL | \
74  CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL)
75 
76 /* Timeout in ms for sending to keyboard controller. */
77 #define CONTROLLER_TIMEOUT 250
78 
79 
80 // NOTE: Similar to machxbox.c!XboxGetHarddiskConfigurationData(),
81 // but with extended geometry support.
82 static
85 {
86  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
87  PCM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
88  EXTENDED_GEOMETRY ExtGeometry;
89  GEOMETRY Geometry;
90  ULONG Size;
91 
92  //
93  // Initialize returned size
94  //
95  *pSize = 0;
96 
97  /* Set 'Configuration Data' value */
98  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
100  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
101  if (PartialResourceList == NULL)
102  {
103  ERR("Failed to allocate resource descriptor\n");
104  return NULL;
105  }
106 
107  memset(PartialResourceList, 0, Size);
108  PartialResourceList->Version = 1;
109  PartialResourceList->Revision = 1;
110  PartialResourceList->Count = 1;
111  PartialResourceList->PartialDescriptors[0].Type =
113 // PartialResourceList->PartialDescriptors[0].ShareDisposition =
114 // PartialResourceList->PartialDescriptors[0].Flags =
115  PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
117 
118  /* Get pointer to geometry data */
119  DiskGeometry = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
120 
121  /* Get the disk geometry */
122  ExtGeometry.Size = sizeof(EXTENDED_GEOMETRY);
123  if (DiskGetExtendedDriveParameters(DriveNumber, &ExtGeometry, ExtGeometry.Size))
124  {
125  DiskGeometry->BytesPerSector = ExtGeometry.BytesPerSector;
126  DiskGeometry->NumberOfCylinders = ExtGeometry.Cylinders;
127  DiskGeometry->SectorsPerTrack = ExtGeometry.SectorsPerTrack;
128  DiskGeometry->NumberOfHeads = ExtGeometry.Heads;
129  }
130  else if (MachDiskGetDriveGeometry(DriveNumber, &Geometry))
131  {
132  DiskGeometry->BytesPerSector = Geometry.BytesPerSector;
133  DiskGeometry->NumberOfCylinders = Geometry.Cylinders;
134  DiskGeometry->SectorsPerTrack = Geometry.Sectors;
135  DiskGeometry->NumberOfHeads = Geometry.Heads;
136  }
137  else
138  {
139  TRACE("Reading disk geometry failed\n");
140  FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
141  return NULL;
142  }
143  TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
144  DriveNumber,
145  DiskGeometry->NumberOfCylinders,
146  DiskGeometry->NumberOfHeads,
147  DiskGeometry->SectorsPerTrack,
148  DiskGeometry->BytesPerSector);
149 
150  //
151  // Return configuration data
152  //
153  *pSize = Size;
154  return PartialResourceList;
155 }
156 
157 static
158 VOID
160 {
161  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
165  ULONG x;
166  ULONG NodeSize = 0;
167  ULONG NodeCount = 0;
169  ULONG FoundNodeCount;
170  int i;
171  ULONG PnpBufferSize;
172  ULONG PnpBufferSizeLimit;
173  ULONG Size;
174  char *Ptr;
175 
177  if (InstData == NULL || strncmp((CHAR*)InstData->Signature, "$PnP", 4))
178  {
179  TRACE("PnP-BIOS not supported\n");
180  return;
181  }
182 
183  TRACE("PnP-BIOS supported\n");
184  TRACE("Signature '%c%c%c%c'\n",
185  InstData->Signature[0], InstData->Signature[1],
186  InstData->Signature[2], InstData->Signature[3]);
187 
188  x = PnpBiosGetDeviceNodeCount(&NodeSize, &NodeCount);
189  if (x == 0x82)
190  {
191  TRACE("PnP-BIOS function 'Get Number of System Device Nodes' not supported\n");
192  return;
193  }
194 
195  NodeCount &= 0xFF; // needed since some fscked up BIOSes return
196  // wrong info (e.g. Mac Virtual PC)
197  // e.g. look: http://my.execpc.com/~geezer/osd/pnp/pnp16.c
198  if (x != 0 || NodeSize == 0 || NodeCount == 0)
199  {
200  ERR("PnP-BIOS failed to enumerate device nodes\n");
201  return;
202  }
203  TRACE("MaxNodeSize %u NodeCount %u\n", NodeSize, NodeCount);
204  TRACE("Estimated buffer size %u\n", NodeSize * NodeCount);
205 
206  /* Set 'Configuration Data' value */
207  PnpBufferSizeLimit = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK)
208  + (NodeSize * NodeCount);
209  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) + PnpBufferSizeLimit;
210  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
211  if (PartialResourceList == NULL)
212  {
213  ERR("Failed to allocate resource descriptor\n");
214  return;
215  }
216  memset(PartialResourceList, 0, Size);
217 
218  /* Initialize resource descriptor */
219  PartialResourceList->Version = 1;
220  PartialResourceList->Revision = 1;
221  PartialResourceList->Count = 1;
222  PartialResourceList->PartialDescriptors[0].Type =
224  PartialResourceList->PartialDescriptors[0].ShareDisposition =
226 
227  /* The buffer starts after PartialResourceList->PartialDescriptors[0] */
228  Ptr = (char *)(PartialResourceList + 1);
229 
230  /* Set installation check data */
231  memcpy (Ptr, InstData, sizeof(CM_PNP_BIOS_INSTALLATION_CHECK));
233  PnpBufferSize = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK);
234 
235  /* Copy device nodes */
236  FoundNodeCount = 0;
237  for (i = 0; i < 0xFF; i++)
238  {
239  NodeNumber = (UCHAR)i;
240 
242  if (x == 0)
243  {
245 
246  TRACE("Node: %u Size %u (0x%x)\n",
247  DeviceNode->Node,
248  DeviceNode->Size,
249  DeviceNode->Size);
250 
251  if (PnpBufferSize + DeviceNode->Size > PnpBufferSizeLimit)
252  {
253  ERR("Buffer too small! Ignoring remaining device nodes.\n");
254  break;
255  }
256 
257  memcpy(Ptr, DeviceNode, DeviceNode->Size);
258 
259  Ptr += DeviceNode->Size;
260  PnpBufferSize += DeviceNode->Size;
261 
262  FoundNodeCount++;
263  if (FoundNodeCount >= NodeCount)
264  break;
265  }
266  }
267 
268  /* Set real data size */
269  PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
270  PnpBufferSize;
271  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) + PnpBufferSize;
272 
273  TRACE("Real buffer size: %u\n", PnpBufferSize);
274  TRACE("Resource size: %u\n", Size);
275 
276  /* Create component key */
277  FldrCreateComponentKey(SystemKey,
278  AdapterClass,
279  MultiFunctionAdapter,
280  0x0,
281  0x0,
282  0xFFFFFFFF,
283  "PNP BIOS",
284  PartialResourceList,
285  Size,
286  &BusKey);
287 
288  (*BusNumber)++;
289 }
290 
291 static
292 VOID
294  UCHAR LineControl)
295 {
296  WRITE_PORT_UCHAR(Port + 3, 0x80); /* set DLAB on */
297  WRITE_PORT_UCHAR(Port, 0x60); /* speed LO byte */
298  WRITE_PORT_UCHAR(Port + 1, 0); /* speed HI byte */
299  WRITE_PORT_UCHAR(Port + 3, LineControl);
300  WRITE_PORT_UCHAR(Port + 1, 0); /* set comm and DLAB to 0 */
301  WRITE_PORT_UCHAR(Port + 4, 0x09); /* DR int enable */
302  READ_PORT_UCHAR(Port + 5); /* clear error bits */
303 }
304 
305 static
306 ULONG
308 {
309  CHAR Buffer[4];
310  ULONG i;
311  ULONG TimeOut;
312  UCHAR LineControl;
313 
314  /* Shutdown mouse or something like that */
315  LineControl = READ_PORT_UCHAR(Port + 4);
316  WRITE_PORT_UCHAR(Port + 4, (LineControl & ~0x02) | 0x01);
317  StallExecutionProcessor(100000);
318 
319  /*
320  * Clear buffer
321  * Maybe there is no serial port although BIOS reported one (this
322  * is the case on Apple hardware), or the serial port is misbehaving,
323  * therefore we must give up after some time.
324  */
325  TimeOut = 200;
326  while (READ_PORT_UCHAR(Port + 5) & 0x01)
327  {
328  if (--TimeOut == 0)
329  return MOUSE_TYPE_NONE;
331  }
332 
333  /*
334  * Send modem control with 'Data Terminal Ready', 'Request To Send' and
335  * 'Output Line 2' message. This enables mouse to identify.
336  */
337  WRITE_PORT_UCHAR(Port + 4, 0x0b);
338 
339  /* Wait 10 milliseconds for the mouse getting ready */
341 
342  /* Read first four bytes, which contains Microsoft Mouse signs */
343  TimeOut = 20;
344  for (i = 0; i < 4; i++)
345  {
346  while ((READ_PORT_UCHAR(Port + 5) & 1) == 0)
347  {
349  --TimeOut;
350  if (TimeOut == 0)
351  return MOUSE_TYPE_NONE;
352  }
354  }
355 
356  TRACE("Mouse data: %x %x %x %x\n",
357  Buffer[0], Buffer[1], Buffer[2], Buffer[3]);
358 
359  /* Check that four bytes for signs */
360  for (i = 0; i < 4; ++i)
361  {
362  if (Buffer[i] == 'B')
363  {
364  /* Sign for Microsoft Ballpoint */
365 // DbgPrint("Microsoft Ballpoint device detected\n");
366 // DbgPrint("THIS DEVICE IS NOT SUPPORTED, YET\n");
367  return MOUSE_TYPE_NONE;
368  }
369  else if (Buffer[i] == 'M')
370  {
371  /* Sign for Microsoft Mouse protocol followed by button specifier */
372  if (i == 3)
373  {
374  /* Overflow Error */
375  return MOUSE_TYPE_NONE;
376  }
377 
378  switch (Buffer[i + 1])
379  {
380  case '3':
381  TRACE("Microsoft Mouse with 3-buttons detected\n");
382  return MOUSE_TYPE_LOGITECH;
383 
384  case 'Z':
385  TRACE("Microsoft Wheel Mouse detected\n");
386  return MOUSE_TYPE_WHEELZ;
387 
388  /* case '2': */
389  default:
390  TRACE("Microsoft Mouse with 2-buttons detected\n");
391  return MOUSE_TYPE_MICROSOFT;
392  }
393  }
394  }
395 
396  return MOUSE_TYPE_NONE;
397 }
398 
399 static ULONG
401 {
402  ULONG TimeOut;
403  ULONG i = 0;
404  char c;
405  char x;
406 
407  WRITE_PORT_UCHAR(Port + 4, 0x09);
408 
409  /* Wait 10 milliseconds for the mouse getting ready */
411 
412  WRITE_PORT_UCHAR(Port + 4, 0x0b);
413 
415 
416  for (;;)
417  {
418  TimeOut = 200;
419  while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
420  {
422  --TimeOut;
423  if (TimeOut == 0)
424  {
425  return 0;
426  }
427  }
428 
430  if (c == 0x08 || c == 0x28)
431  break;
432  }
433 
434  Buffer[i++] = c;
435  x = c + 1;
436 
437  for (;;)
438  {
439  TimeOut = 200;
440  while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
441  {
443  --TimeOut;
444  if (TimeOut == 0)
445  return 0;
446  }
448  Buffer[i++] = c;
449  if (c == x)
450  break;
451  if (i >= 256)
452  break;
453  }
454 
455  return i;
456 }
457 
458 static
459 VOID
461  PUCHAR Base)
462 {
463  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
464  char Buffer[256];
465  CHAR Identifier[256];
466  PCONFIGURATION_COMPONENT_DATA PeripheralKey;
467  ULONG MouseType;
468  ULONG Size, Length;
469  ULONG i;
470  ULONG j;
471  ULONG k;
472 
473  TRACE("DetectSerialPointerPeripheral()\n");
474 
475  Identifier[0] = 0;
476 
478  MouseType = DetectSerialMouse(Base);
479 
480  if (MouseType != MOUSE_TYPE_NONE)
481  {
483  TRACE( "PnP ID length: %u\n", Length);
484 
485  if (Length != 0)
486  {
487  /* Convert PnP sting to ASCII */
488  if (Buffer[0] == 0x08)
489  {
490  for (i = 0; i < Length; i++)
491  Buffer[i] += 0x20;
492  }
493  Buffer[Length] = 0;
494 
495  TRACE("PnP ID string: %s\n", Buffer);
496 
497  /* Copy PnpId string */
498  for (i = 0; i < 7; i++)
499  {
500  Identifier[i] = Buffer[3 + i];
501  }
502  memcpy(&Identifier[7],
503  L" - ",
504  3 * sizeof(WCHAR));
505 
506  /* Skip device serial number */
507  i = 10;
508  if (Buffer[i] == '\\')
509  {
510  for (j = ++i; i < Length; ++i)
511  {
512  if (Buffer[i] == '\\')
513  break;
514  }
515  if (i >= Length)
516  i -= 3;
517  }
518 
519  /* Skip PnP class */
520  if (Buffer[i] == '\\')
521  {
522  for (j = ++i; i < Length; ++i)
523  {
524  if (Buffer[i] == '\\')
525  break;
526  }
527 
528  if (i >= Length)
529  i -= 3;
530  }
531 
532  /* Skip compatible PnP Id */
533  if (Buffer[i] == '\\')
534  {
535  for (j = ++i; i < Length; ++i)
536  {
537  if (Buffer[i] == '\\')
538  break;
539  }
540  if (Buffer[j] == '*')
541  ++j;
542  if (i >= Length)
543  i -= 3;
544  }
545 
546  /* Get product description */
547  if (Buffer[i] == '\\')
548  {
549  for (j = ++i; i < Length; ++i)
550  {
551  if (Buffer[i] == ';')
552  break;
553  }
554  if (i >= Length)
555  i -= 3;
556  if (i > j + 1)
557  {
558  for (k = 0; k < i - j; k++)
559  {
560  Identifier[k + 10] = Buffer[k + j];
561  }
562  Identifier[10 + (i - j)] = 0;
563  }
564  }
565 
566  TRACE("Identifier string: %s\n", Identifier);
567  }
568 
569  if (Length == 0 || strlen(Identifier) < 11)
570  {
571  switch (MouseType)
572  {
573  case MOUSE_TYPE_LOGITECH:
574  strcpy(Identifier, "LOGITECH SERIAL MOUSE");
575  break;
576 
577  case MOUSE_TYPE_WHEELZ:
578  strcpy(Identifier, "MICROSOFT SERIAL MOUSE WITH WHEEL");
579  break;
580 
582  default:
583  strcpy(Identifier, "MICROSOFT SERIAL MOUSE");
584  break;
585  }
586  }
587 
588  /* Set 'Configuration Data' value */
589  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
591  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
592  if (PartialResourceList == NULL)
593  {
594  ERR("Failed to allocate resource descriptor\n");
595  return;
596  }
597  memset(PartialResourceList, 0, Size);
598  PartialResourceList->Version = 1;
599  PartialResourceList->Revision = 1;
600  PartialResourceList->Count = 0;
601 
602  /* Create 'PointerPeripheral' key */
603  FldrCreateComponentKey(ControllerKey,
605  PointerPeripheral,
606  Input,
607  0x0,
608  0xFFFFFFFF,
609  Identifier,
610  PartialResourceList,
611  Size,
612  &PeripheralKey);
613 
614  TRACE("Created key: PointerPeripheral\\0\n");
615  }
616 }
617 
618 static
619 VOID
621 {
622  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
623  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
624  PCM_SERIAL_DEVICE_DATA SerialDeviceData;
625  ULONG Irq[MAX_COM_PORTS] = {4, 3, 4, 3};
626  ULONG Base;
627  CHAR Buffer[80];
628  PUSHORT BasePtr;
629  ULONG ControllerNumber = 0;
630  PCONFIGURATION_COMPONENT_DATA ControllerKey;
631  ULONG i;
632  ULONG Size;
633 
634  TRACE("DetectSerialPorts()\n");
635 
636  /*
637  * The BIOS data area 0x400 holds the address of the first valid COM port.
638  * Each COM port address is stored in a 2-byte field.
639  * Infos at: http://www.bioscentral.com/misc/bda.htm
640  */
641  BasePtr = (PUSHORT)0x400;
642 
643  for (i = 0; i < MAX_COM_PORTS; i++, BasePtr++)
644  {
645  Base = (ULONG) * BasePtr;
646  if ((Base == 0) || !CpDoesPortExist(UlongToPtr(Base)))
647  continue;
648 
649  TRACE("Found COM%u port at 0x%x\n", i + 1, Base);
650 
651  /* Set 'Identifier' value */
652  sprintf(Buffer, "COM%ld", i + 1);
653 
654  /* Build full device descriptor */
655  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
656  2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) +
657  sizeof(CM_SERIAL_DEVICE_DATA);
658  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
659  if (PartialResourceList == NULL)
660  {
661  ERR("Failed to allocate resource descriptor\n");
662  continue;
663  }
664  memset(PartialResourceList, 0, Size);
665 
666  /* Initialize resource descriptor */
667  PartialResourceList->Version = 1;
668  PartialResourceList->Revision = 1;
669  PartialResourceList->Count = 3;
670 
671  /* Set IO Port */
672  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
673  PartialDescriptor->Type = CmResourceTypePort;
675  PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
676  PartialDescriptor->u.Port.Start.LowPart = Base;
677  PartialDescriptor->u.Port.Start.HighPart = 0x0;
678  PartialDescriptor->u.Port.Length = 7;
679 
680  /* Set Interrupt */
681  PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
682  PartialDescriptor->Type = CmResourceTypeInterrupt;
683  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
684  PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
685  PartialDescriptor->u.Interrupt.Level = Irq[i];
686  PartialDescriptor->u.Interrupt.Vector = Irq[i];
687  PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
688 
689  /* Set serial data (device specific) */
690  PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
691  PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
692  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
693  PartialDescriptor->Flags = 0;
694  PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_SERIAL_DEVICE_DATA);
695 
696  SerialDeviceData =
697  (PCM_SERIAL_DEVICE_DATA)&PartialResourceList->PartialDescriptors[3];
698  SerialDeviceData->BaudClock = 1843200; /* UART Clock frequency (Hertz) */
699 
700  /* Create controller key */
701  FldrCreateComponentKey(BusKey,
703  SerialController,
705  ControllerNumber,
706  0xFFFFFFFF,
707  Buffer,
708  PartialResourceList,
709  Size,
710  &ControllerKey);
711 
713  {
714  /* Detect serial mouse */
716  }
717 
718  ControllerNumber++;
719  }
720 }
721 
722 static VOID
724 {
725  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
726  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
727  ULONG Irq[MAX_LPT_PORTS] = {7, 5, (ULONG) - 1};
728  CHAR Buffer[80];
729  PCONFIGURATION_COMPONENT_DATA ControllerKey;
730  PUSHORT BasePtr;
731  ULONG Base;
732  ULONG ControllerNumber = 0;
733  ULONG i;
734  ULONG Size;
735 
736  TRACE("DetectParallelPorts() called\n");
737 
738  /*
739  * The BIOS data area 0x408 holds the address of the first valid LPT port.
740  * Each LPT port address is stored in a 2-byte field.
741  * Infos at: http://www.bioscentral.com/misc/bda.htm
742  */
743  BasePtr = (PUSHORT)0x408;
744 
745  for (i = 0; i < MAX_LPT_PORTS; i++, BasePtr++)
746  {
747  Base = (ULONG) * BasePtr;
748  if (Base == 0)
749  continue;
750 
751  TRACE("Parallel port %u: %x\n", ControllerNumber, Base);
752 
753  /* Set 'Identifier' value */
754  sprintf(Buffer, "PARALLEL%ld", i + 1);
755 
756  /* Build full device descriptor */
757  Size = sizeof(CM_PARTIAL_RESOURCE_LIST);
758  if (Irq[i] != (ULONG) - 1)
760 
761  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
762  if (PartialResourceList == NULL)
763  {
764  ERR("Failed to allocate resource descriptor\n");
765  continue;
766  }
767  memset(PartialResourceList, 0, Size);
768 
769  /* Initialize resource descriptor */
770  PartialResourceList->Version = 1;
771  PartialResourceList->Revision = 1;
772  PartialResourceList->Count = (Irq[i] != (ULONG) - 1) ? 2 : 1;
773 
774  /* Set IO Port */
775  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
776  PartialDescriptor->Type = CmResourceTypePort;
778  PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
779  PartialDescriptor->u.Port.Start.LowPart = Base;
780  PartialDescriptor->u.Port.Start.HighPart = 0x0;
781  PartialDescriptor->u.Port.Length = 3;
782 
783  /* Set Interrupt */
784  if (Irq[i] != (ULONG) - 1)
785  {
786  PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
787  PartialDescriptor->Type = CmResourceTypeInterrupt;
788  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
789  PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
790  PartialDescriptor->u.Interrupt.Level = Irq[i];
791  PartialDescriptor->u.Interrupt.Vector = Irq[i];
792  PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
793  }
794 
795  /* Create controller key */
796  FldrCreateComponentKey(BusKey,
798  ParallelController,
799  Output,
800  ControllerNumber,
801  0xFFFFFFFF,
802  Buffer,
803  PartialResourceList,
804  Size,
805  &ControllerKey);
806 
807  ControllerNumber++;
808  }
809 
810  TRACE("DetectParallelPorts() done\n");
811 }
812 
813 // static
814 BOOLEAN
816 {
817  UCHAR Status;
818  UCHAR Scancode;
819  ULONG Loops;
820  BOOLEAN Result = TRUE;
821 
822  /* Identify device */
824 
825  /* Wait for reply */
826  for (Loops = 0; Loops < 100; Loops++)
827  {
831  break;
832  }
833 
835  {
836  /* PC/XT keyboard or no keyboard */
837  Result = FALSE;
838  }
839 
841  if (Scancode != 0xFA)
842  {
843  /* No ACK received */
844  Result = FALSE;
845  }
846 
848 
851  {
852  /* Found AT keyboard */
853  return Result;
854  }
855 
857  if (Scancode != 0xAB)
858  {
859  /* No 0xAB received */
860  Result = FALSE;
861  }
862 
864 
867  {
868  /* No byte in buffer */
869  Result = FALSE;
870  }
871 
873  if (Scancode != 0x41)
874  {
875  /* No 0x41 received */
876  Result = FALSE;
877  }
878 
879  /* Found MF-II keyboard */
880  return Result;
881 }
882 
883 static VOID
885 {
886  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
887  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
888  PCM_KEYBOARD_DEVICE_DATA KeyboardData;
889  PCONFIGURATION_COMPONENT_DATA PeripheralKey;
890  ULONG Size;
891 
892  /* HACK: don't call DetectKeyboardDevice() as it fails in Qemu 0.8.2
893  if (DetectKeyboardDevice()) */
894  {
895  /* Set 'Configuration Data' value */
896  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
897  sizeof(CM_KEYBOARD_DEVICE_DATA);
898  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
899  if (PartialResourceList == NULL)
900  {
901  ERR("Failed to allocate resource descriptor\n");
902  return;
903  }
904 
905  /* Initialize resource descriptor */
906  memset(PartialResourceList, 0, Size);
907  PartialResourceList->Version = 1;
908  PartialResourceList->Revision = 1;
909  PartialResourceList->Count = 1;
910 
911  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
912  PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
913  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
914  PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_KEYBOARD_DEVICE_DATA);
915 
916  KeyboardData = (PCM_KEYBOARD_DEVICE_DATA)(PartialDescriptor + 1);
917  KeyboardData->Version = 1;
918  KeyboardData->Revision = 1;
919  KeyboardData->Type = 4;
920  KeyboardData->Subtype = 0;
921  KeyboardData->KeyboardFlags = 0x20;
922 
923  /* Create controller key */
924  FldrCreateComponentKey(ControllerKey,
926  KeyboardPeripheral,
927  Input | ConsoleIn,
928  0x0,
929  0xFFFFFFFF,
930  "PCAT_ENHANCED",
931  PartialResourceList,
932  Size,
933  &PeripheralKey);
934  TRACE("Created key: KeyboardPeripheral\\0\n");
935  }
936 }
937 
938 static
939 VOID
941 {
942  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
943  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
944  PCONFIGURATION_COMPONENT_DATA ControllerKey;
945  ULONG Size;
946 
947  /* Set 'Configuration Data' value */
948  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
949  2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
950  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
951  if (PartialResourceList == NULL)
952  {
953  ERR("Failed to allocate resource descriptor\n");
954  return;
955  }
956 
957  /* Initialize resource descriptor */
958  memset(PartialResourceList, 0, Size);
959  PartialResourceList->Version = 1;
960  PartialResourceList->Revision = 1;
961  PartialResourceList->Count = 3;
962 
963  /* Set Interrupt */
964  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
965  PartialDescriptor->Type = CmResourceTypeInterrupt;
966  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
967  PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
968  PartialDescriptor->u.Interrupt.Level = 1;
969  PartialDescriptor->u.Interrupt.Vector = 1;
970  PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
971 
972  /* Set IO Port 0x60 */
973  PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
974  PartialDescriptor->Type = CmResourceTypePort;
976  PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
977  PartialDescriptor->u.Port.Start.LowPart = 0x60;
978  PartialDescriptor->u.Port.Start.HighPart = 0x0;
979  PartialDescriptor->u.Port.Length = 1;
980 
981  /* Set IO Port 0x64 */
982  PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
983  PartialDescriptor->Type = CmResourceTypePort;
985  PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
986  PartialDescriptor->u.Port.Start.LowPart = 0x64;
987  PartialDescriptor->u.Port.Start.HighPart = 0x0;
988  PartialDescriptor->u.Port.Length = 1;
989 
990  /* Create controller key */
991  FldrCreateComponentKey(BusKey,
993  KeyboardController,
994  Input | ConsoleIn,
995  0x0,
996  0xFFFFFFFF,
997  NULL,
998  PartialResourceList,
999  Size,
1000  &ControllerKey);
1001  TRACE("Created key: KeyboardController\\0\n");
1002 
1003  DetectKeyboardPeripheral(ControllerKey);
1004 }
1005 
1006 static
1007 VOID
1009 {
1010  ULONG Timeout;
1011  UCHAR Status;
1012 
1013  for (Timeout = 0; Timeout < CONTROLLER_TIMEOUT; Timeout++)
1014  {
1017  return;
1018 
1019  /* Sleep for one millisecond */
1021  }
1022 }
1023 
1024 static
1025 BOOLEAN
1027 {
1028 #if 1
1029  /* Current detection is too unreliable. Just do as if
1030  * the PS/2 aux port is always present
1031  */
1032  return TRUE;
1033 #else
1034  ULONG Loops;
1035  UCHAR Status;
1036 
1037  /* Put the value 0x5A in the output buffer using the
1038  * "WriteAuxiliary Device Output Buffer" command (0xD3).
1039  * Poll the Status Register for a while to see if the value really turns up
1040  * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1041  * to 1 in the Status Register, we assume this controller has an
1042  * Auxiliary Port (a.k.a. Mouse Port).
1043  */
1048 
1049  /* 0x5A is a random dummy value */
1051  0x5A);
1052 
1053  for (Loops = 0; Loops < 10; Loops++)
1054  {
1055  StallExecutionProcessor(10000);
1058  break;
1059  }
1060 
1062 
1064 #endif
1065 }
1066 
1067 static
1068 BOOLEAN
1070 {
1071  UCHAR Scancode;
1072  UCHAR Status;
1073  ULONG Loops;
1074  BOOLEAN Result = TRUE;
1075 
1080 
1081  /* Identify device */
1083 
1084  /* Wait for reply */
1085  for (Loops = 0; Loops < 100; Loops++)
1086  {
1087  StallExecutionProcessor(10000);
1090  break;
1091  }
1092 
1095  Result = FALSE;
1096 
1098  if (Scancode != 0xFA)
1099  Result = FALSE;
1100 
1101  StallExecutionProcessor(10000);
1102 
1105  Result = FALSE;
1106 
1108  if (Scancode != 0x00)
1109  Result = FALSE;
1110 
1111  return Result;
1112 }
1113 
1114 // FIXME: Missing: DetectPS2Peripheral!! (for corresponding 'PointerPeripheral')
1115 
1116 static
1117 VOID
1119 {
1120  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1121  PCONFIGURATION_COMPONENT_DATA ControllerKey;
1122  PCONFIGURATION_COMPONENT_DATA PeripheralKey;
1123  ULONG Size;
1124 
1125  if (DetectPS2AuxPort())
1126  {
1127  TRACE("Detected PS2 port\n");
1128 
1129  PartialResourceList = FrLdrHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST), TAG_HW_RESOURCE_LIST);
1130  if (PartialResourceList == NULL)
1131  {
1132  ERR("Failed to allocate resource descriptor\n");
1133  return;
1134  }
1135  memset(PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST));
1136 
1137  /* Initialize resource descriptor */
1138  PartialResourceList->Version = 1;
1139  PartialResourceList->Revision = 1;
1140  PartialResourceList->Count = 1;
1141 
1142  /* Set Interrupt */
1143  PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeInterrupt;
1145  PartialResourceList->PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1146  PartialResourceList->PartialDescriptors[0].u.Interrupt.Level = 12;
1147  PartialResourceList->PartialDescriptors[0].u.Interrupt.Vector = 12;
1148  PartialResourceList->PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF;
1149 
1150  /* Create controller key */
1151  FldrCreateComponentKey(BusKey,
1153  PointerController,
1154  Input,
1155  0x0,
1156  0xFFFFFFFF,
1157  NULL,
1158  PartialResourceList,
1159  sizeof(CM_PARTIAL_RESOURCE_LIST),
1160  &ControllerKey);
1161  TRACE("Created key: PointerController\\0\n");
1162 
1163  if (DetectPS2AuxDevice())
1164  {
1165  TRACE("Detected PS2 mouse\n");
1166 
1167  /* Initialize resource descriptor */
1168  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1170  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1171  if (PartialResourceList == NULL)
1172  {
1173  ERR("Failed to allocate resource descriptor\n");
1174  return;
1175  }
1176  memset(PartialResourceList, 0, Size);
1177  PartialResourceList->Version = 1;
1178  PartialResourceList->Revision = 1;
1179  PartialResourceList->Count = 0;
1180 
1181  /* Create peripheral key */
1182  FldrCreateComponentKey(ControllerKey,
1184  PointerPeripheral,
1185  Input,
1186  0x0,
1187  0xFFFFFFFF,
1188  "MICROSOFT PS2 MOUSE",
1189  PartialResourceList,
1190  Size,
1191  &PeripheralKey);
1192  TRACE("Created key: PointerPeripheral\\0\n");
1193  }
1194  }
1195 }
1196 
1197 static VOID
1199 {
1200  CHAR Buffer[80];
1201  PCONFIGURATION_COMPONENT_DATA ControllerKey;
1202  USHORT VesaVersion;
1203 
1204  /* FIXME: Set 'ComponentInformation' value */
1205 
1206  VesaVersion = BiosIsVesaSupported();
1207  if (VesaVersion != 0)
1208  {
1209  TRACE("VESA version %c.%c\n",
1210  (VesaVersion >> 8) + '0',
1211  (VesaVersion & 0xFF) + '0');
1212  }
1213  else
1214  {
1215  TRACE("VESA not supported\n");
1216  }
1217 
1218  if (VesaVersion >= 0x0200)
1219  {
1220  strcpy(Buffer, "VBE Display");
1221  }
1222  else
1223  {
1224  strcpy(Buffer, "VGA Display");
1225  }
1226 
1227  FldrCreateComponentKey(BusKey,
1229  DisplayController,
1230  0x0,
1231  0x0,
1232  0xFFFFFFFF,
1233  Buffer,
1234  NULL,
1235  0,
1236  &ControllerKey);
1237  TRACE("Created key: DisplayController\\0\n");
1238 
1239  /* FIXME: Add display peripheral (monitor) data */
1240  if (VesaVersion != 0)
1241  {
1242  if (BiosIsVesaDdcSupported())
1243  {
1244  TRACE("VESA/DDC supported!\n");
1245  if (BiosVesaReadEdid())
1246  {
1247  TRACE("EDID data read successfully!\n");
1248 
1249  }
1250  }
1251  }
1252 }
1253 
1254 static
1255 VOID
1257 {
1258  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1260  ULONG Size;
1261 
1262  /* Set 'Configuration Data' value */
1263  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1265  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1266  if (PartialResourceList == NULL)
1267  {
1268  ERR("Failed to allocate resource descriptor\n");
1269  return;
1270  }
1271 
1272  /* Initialize resource descriptor */
1273  memset(PartialResourceList, 0, Size);
1274  PartialResourceList->Version = 1;
1275  PartialResourceList->Revision = 1;
1276  PartialResourceList->Count = 0;
1277 
1278  /* Create new bus key */
1279  FldrCreateComponentKey(SystemKey,
1280  AdapterClass,
1281  MultiFunctionAdapter,
1282  0x0,
1283  0x0,
1284  0xFFFFFFFF,
1285  "ISA",
1286  PartialResourceList,
1287  Size,
1288  &BusKey);
1289 
1290  /* Increment bus number */
1291  (*BusNumber)++;
1292 
1293  /* Detect ISA/BIOS devices */
1294  DetectBiosDisks(SystemKey, BusKey);
1295  DetectSerialPorts(BusKey);
1296  DetectParallelPorts(BusKey);
1297  DetectKeyboardController(BusKey);
1298  DetectPS2Mouse(BusKey);
1299  DetectDisplayController(BusKey);
1300 
1301  /* FIXME: Detect more ISA devices */
1302 }
1303 
1306 {
1308  ULONG BusNumber = 0;
1309 
1310  TRACE("DetectHardware()\n");
1311 
1312  /* Create the 'System' key */
1313  FldrCreateSystemKey(&SystemKey);
1314  // TODO: Discover and set the machine type as the Component->Identifier
1315 
1317 
1318  /* Detect buses */
1319  DetectPciBios(SystemKey, &BusNumber);
1320  DetectApmBios(SystemKey, &BusNumber);
1321  DetectPnpBios(SystemKey, &BusNumber);
1322  DetectIsaBios(SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
1323  DetectAcpiBios(SystemKey, &BusNumber);
1324 
1325  // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
1326  // CM_ROM_BLOCK data into the 'System' key's configuration data.
1327 
1328  TRACE("DetectHardware() Done\n");
1329  return SystemKey;
1330 }
1331 
1332 VOID
1334 {
1335  REGS Regs;
1336 
1337  /* Select APM 1.0+ function */
1338  Regs.b.ah = 0x53;
1339 
1340  /* Function 05h: CPU idle */
1341  Regs.b.al = 0x05;
1342 
1343  /* Call INT 15h */
1344  Int386(0x15, &Regs, &Regs);
1345 
1346  /* Check if successfull (CF set on error) */
1347  if (INT386_SUCCESS(Regs))
1348  return;
1349 
1350  /*
1351  * No futher processing here.
1352  * Optionally implement HLT instruction handling.
1353  */
1354 }
1355 
1356 
1357 /******************************************************************************/
1358 
1359 VOID
1360 PcMachInit(const char *CmdLine)
1361 {
1362  /* Setup vtbl */
1378  MachVtbl.Beep = PcBeep;
1389 
1390  // DiskGetPartitionEntry = DiskGetMbrPartitionEntry; // Default
1391 }
1392 
1393 VOID
1395 {
1396  /* On PC, prepare video and turn off the floppy motor */
1399 }
1400 
1401 /* EOF */
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
CPPORT Port[4]
Definition: headless.c:34
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
static VOID DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:620
PFREELDR_MEMORY_DESCRIPTOR(* GetMemoryMap)(PULONG MaxMemoryMapSize)
Definition: machine.h:62
char CmdLine[0x100]
Definition: mach.c:35
#define IN
Definition: typedefs.h:38
#define CONTROLLER_STATUS_INPUT_BUFFER_FULL
Definition: machpc.c:66
#define TRUE
Definition: types.h:120
FORCEINLINE VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: mm.h:170
#define MAX_LPT_PORTS
Definition: machpc.c:29
GLint x0
Definition: linetemp.h:95
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 ACPI_NOTIFY_HANDLER void *Context ACPI_ADR_SPACE_TYPE ACPI_ADR_SPACE_HANDLER ACPI_ADR_SPACE_SETUP Setup
Definition: acpixf.h:816
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@371 Port
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
VOID PcVideoSync(VOID)
Definition: pcvideo.c:1089
#define CONTROLLER_TIMEOUT
Definition: machpc.c:77
ULONG Cylinders
Definition: disk.h:26
VOID(* VideoClearScreen)(UCHAR Attr)
Definition: machine.h:45
#define DiskReadBuffer
Definition: hardware.h:33
unsigned char * PUCHAR
Definition: retypes.h:3
struct _CM_PNP_BIOS_INSTALLATION_CHECK * PCM_PNP_BIOS_INSTALLATION_CHECK
Definition: arc.h:82
char CHAR
Definition: xmlstorage.h:175
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
PCONFIGURATION_COMPONENT_DATA(* HwDetect)(VOID)
Definition: machine.h:75
struct _CM_SERIAL_DEVICE_DATA CM_SERIAL_DEVICE_DATA
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2327
BOOLEAN(* DiskGetBootPath)(PCHAR BootPath, ULONG Size)
Definition: machine.h:64
VOID(* VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth)
Definition: machine.h:47
Definition: arc.h:84
unsigned char ah
Definition: pcbios.h:112
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369 u
static ULONG GetSerialMousePnpId(PUCHAR Port, char *Buffer)
Definition: machpc.c:400
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@372 Interrupt
#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL
Definition: machpc.c:65
struct _CM_PNP_BIOS_DEVICE_NODE * PCM_PNP_BIOS_DEVICE_NODE
static VOID DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey, PUCHAR Base)
Definition: machpc.c:460
BOOLEAN(* VideoIsPaletteFixed)(VOID)
Definition: machine.h:53
BOOLEAN Rs232PortInUse(PUCHAR Base)
Definition: rs232.c:132
ULONG Cylinders
Definition: disk.h:41
#define CmResourceTypePort
Definition: hwresource.cpp:123
uint32_t ULONG_PTR
Definition: typedefs.h:63
_Out_ PUSHORT NodeNumber
Definition: iofuncs.h:2567
int __cdecl Int386(int ivec, REGS *in, REGS *out)
#define sprintf(buf, format,...)
Definition: sprintf.c:55
BOOLEAN NTAPI CpDoesPortExist(IN PUCHAR Address)
Definition: cport.c:227
ULONG __cdecl PnpBiosGetDeviceNode(UCHAR *NodeId, UCHAR *NodeBuffer)
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData
Definition: hardware.c:42
ULONG PcDiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: pcdisk.c:555
static BOOLEAN DetectPS2AuxDevice(VOID)
Definition: machpc.c:1069
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
BOOLEAN PcInitializeBootDevices(VOID)
Definition: hwdisk.c:349
VOID PcVideoHideShowTextCursor(BOOLEAN Show)
Definition: pcvideo.c:986
#define INT386_SUCCESS(regs)
Definition: pcbios.h:159
VOID PcVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
Definition: pcvideo.c:961
static VOID DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:940
ULONG SectorsPerTrack
Definition: disk.h:43
static BOOLEAN DetectPS2AuxPort(VOID)
Definition: machpc.c:1026
#define MOUSE_TYPE_MICROSOFT
Definition: machpc.c:34
VOID PcVideoClearScreen(UCHAR Attr)
Definition: pcvideo.c:1040
static ULONG DetectSerialMouse(PUCHAR Port)
Definition: machpc.c:307
BOOLEAN DiskGetExtendedDriveParameters(UCHAR DriveNumber, PVOID Buffer, USHORT BufferSize)
Definition: pcdisk.c:422
static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: machpc.c:84
VOID StallExecutionProcessor(ULONG Microseconds)
Definition: hardware.c:57
unsigned char BOOLEAN
BOOLEAN PcDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: pcdisk.c:495
BOOLEAN(* DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry)
Definition: machine.h:66
VOID(* VideoSetTextCursorPosition)(UCHAR X, UCHAR Y)
Definition: machine.h:49
smooth NULL
Definition: ftsmooth.c:416
_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:426
PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap(ULONG *MemoryMapSize)
Definition: pcmem.c:543
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@378 DeviceSpecificData
Definition: bufpool.h:45
#define MOUSE_TYPE_NONE
Definition: machpc.c:32
ULONG __cdecl PnpBiosGetDeviceNodeCount(ULONG *NodeSize, ULONG *NodeCount)
void * PVOID
Definition: retypes.h:9
TIMEINFO *(* GetTime)(VOID)
Definition: machine.h:70
BOOLEAN BiosIsVesaDdcSupported(VOID)
Definition: i386vid.c:243
static VOID DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:723
struct _CM_PNP_BIOS_INSTALLATION_CHECK CM_PNP_BIOS_INSTALLATION_CHECK
#define MachDiskGetDriveGeometry(Drive, Geom)
Definition: machine.h:122
#define UlongToPtr(u)
Definition: config.h:106
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
USHORT BiosIsVesaSupported(VOID)
Definition: i386vid.c:161
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
BOOLEAN(* InitializeBootDevices)(VOID)
Definition: machine.h:74
BOOLEAN PcDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: pcdisk.c:387
ULONG Sectors
Definition: disk.h:28
#define TRACE(s)
Definition: solgame.cpp:4
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
static VOID DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: machpc.c:159
#define MOUSE_TYPE_WHEELZ
Definition: machpc.c:38
VOID(* VideoGetPaletteColor)(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: machine.h:55
VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayModeName, BOOLEAN Init)
Definition: pcvideo.c:873
BOOLEAN PcConsKbHit(VOID)
Definition: pccons.c:69
BOOLEAN PcVideoIsPaletteFixed(VOID)
Definition: pcvideo.c:1065
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: pcvideo.c:1071
VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: hardware.c:353
VOID PcPrepareForReactOS(IN BOOLEAN Setup)
Definition: machpc.c:1394
static VOID DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1118
#define CONTROLLER_COMMAND_WRITE_MOUSE
Definition: machpc.c:62
static VOID PS2ControllerWait(VOID)
Definition: machpc.c:1008
#define CONTROLLER_REGISTER_DATA
Definition: machpc.c:48
const GLubyte * c
Definition: glext.h:8905
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
PCONFIGURATION_COMPONENT_DATA PcHwDetect(VOID)
Definition: machpc.c:1305
VOID DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwpci.c:175
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static VOID InitializeSerialPort(PUCHAR Port, UCHAR LineControl)
Definition: machpc.c:293
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwacpi.c:54
#define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
Definition: machpc.c:70
Definition: Node.h:9
BOOLEAN(* DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: machine.h:65
BOOLEAN(* ConsKbHit)(VOID)
Definition: machine.h:42
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _CM_SERIAL_DEVICE_DATA * PCM_SERIAL_DEVICE_DATA
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
VOID(* VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: machine.h:51
VOID PcMachInit(const char *CmdLine)
Definition: machpc.c:1360
BOOLEAN BiosVesaReadEdid(VOID)
Definition: i386vid.c:273
static const WCHAR L[]
Definition: oid.c:1250
DBG_DEFAULT_CHANNEL(HWDETECT)
BYTEREGS b
Definition: pcbios.h:143
Definition: arc.h:85
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define MAX_COM_PORTS
Definition: machpc.c:28
VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: pcvideo.c:1056
unsigned char al
Definition: pcbios.h:111
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
VOID(* VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: machine.h:54
USHORT Size
Definition: disk.h:39
VOID PcBeep(VOID)
Definition: i386rtl.c:25
VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: pcvideo.c:931
VOID NTAPI 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 PCHAR IdentifierString, IN PCM_PARTIAL_RESOURCE_LIST ResourceList, IN ULONG Size, OUT PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:147
ULONG(* VideoGetBufferSize)(VOID)
Definition: machine.h:48
Status
Definition: gdiplustypes.h:24
VOID PcVideoPrepareForReactOS(IN BOOLEAN Setup)
Definition: pcvideo.c:1112
int(* ConsGetCh)(VOID)
Definition: machine.h:43
#define ERR(fmt,...)
Definition: debug.h:109
ULONG(* DiskGetCacheableBlockCount)(UCHAR DriveNumber)
Definition: machine.h:67
VOID(* ConsPutChar)(int Ch)
Definition: machine.h:41
BOOLEAN PcDiskGetBootPath(OUT PCHAR BootPath, IN ULONG Size)
Definition: pcdisk.c:578
ULONG BytesPerSector
Definition: disk.h:29
USHORT BytesPerSector
Definition: disk.h:45
static ULONG Timeout
Definition: ping.c:61
static VOID DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: machpc.c:1256
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
Definition: arc.h:83
unsigned short USHORT
Definition: pedump.c:61
VOID(* HwIdle)(VOID)
Definition: machine.h:76
ULONG Heads
Definition: disk.h:42
struct _CM_KEYBOARD_DEVICE_DATA CM_KEYBOARD_DEVICE_DATA
BOOLEAN DetectKeyboardDevice(VOID)
Definition: machpc.c:815
Definition: disk.h:24
ULONG_PTR __cdecl PnpBiosSupported(VOID)
VOID PcHwIdle(VOID)
Definition: machpc.c:1333
struct _EXTENDED_GEOMETRY EXTENDED_GEOMETRY
static VOID DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1198
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define MOUSE_TYPE_LOGITECH
Definition: machpc.c:36
VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: pcvideo.c:999
#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER
Definition: machpc.c:61
VOID(* VideoSync)(VOID)
Definition: machine.h:56
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
static VOID DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: machpc.c:884
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define c
Definition: ke_i.h:80
VOID PcVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: pcvideo.c:1080
unsigned int ULONG
Definition: retypes.h:1
Definition: pcbios.h:138
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539
VOID(* VideoCopyOffScreenBufferToVRAM)(PVOID Buffer)
Definition: machine.h:52
VIDEODISPLAYMODE(* VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init)
Definition: machine.h:46
VOID NTAPI FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode)
Definition: archwsup.c:89
#define CONTROLLER_REGISTER_STATUS
Definition: machpc.c:46
struct _CM_KEYBOARD_DEVICE_DATA * PCM_KEYBOARD_DEVICE_DATA
#define CONTROLLER_REGISTER_CONTROL
Definition: machpc.c:47
TIMEINFO * PcGetTime(VOID)
Definition: pcrtc.c:24
MACHVTBL MachVtbl
Definition: machine.c:21
VOID(* Beep)(VOID)
Definition: machine.h:57
#define memset(x, y, z)
Definition: compat.h:39
int k
Definition: mpi.c:3369
ULONG PcVideoGetBufferSize(VOID)
Definition: pcvideo.c:955
int PcConsGetCh(void)
Definition: pccons.c:90
unsigned short * PUSHORT
Definition: retypes.h:2
VOID PcConsPutChar(int Ch)
Definition: pccons.c:28
struct _CM_DISK_GEOMETRY_DEVICE_DATA CM_DISK_GEOMETRY_DEVICE_DATA
#define TAG_HW_RESOURCE_LIST
Definition: hardware.h:26
VOID(* VideoHideShowTextCursor)(BOOLEAN Show)
Definition: machine.h:50
VOID(* PrepareForReactOS)(IN BOOLEAN Setup)
Definition: machine.h:58
VOID DiskStopFloppyMotor(VOID)
Definition: macharm.c:62
ULONG Heads
Definition: disk.h:27
VOID DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwapm.c:58