ReactOS 0.4.15-dev-8102-g108db8f
machpc.c File Reference
#include <freeldr.h>
#include <cportlib/cportlib.h>
#include "../ntldr/ntldropts.h"
#include <debug.h>
Include dependency graph for machpc.c:

Go to the source code of this file.

Macros

#define MAX_COM_PORTS   4
 
#define MAX_LPT_PORTS   3
 
#define MOUSE_TYPE_NONE   0
 
#define MOUSE_TYPE_MICROSOFT   1
 
#define MOUSE_TYPE_LOGITECH   2
 
#define MOUSE_TYPE_WHEELZ   3
 
#define MOUSE_TYPE_MOUSESYSTEMS   4
 
#define INPORT_REGISTER_CONTROL   0x00
 
#define INPORT_REGISTER_DATA   0x01
 
#define INPORT_REGISTER_SIGNATURE   0x02
 
#define INPORT_REG_MODE   0x07
 
#define INPORT_RESET   0x80
 
#define INPORT_MODE_BASE   0x10
 
#define INPORT_TEST_IRQ   0x16
 
#define INPORT_SIGNATURE   0xDE
 
#define PIC1_CONTROL_PORT   0x20
 
#define PIC1_DATA_PORT   0x21
 
#define PIC2_CONTROL_PORT   0xA0
 
#define PIC2_DATA_PORT   0xA1
 
#define CONTROLLER_REGISTER_STATUS   0x64
 
#define CONTROLLER_REGISTER_CONTROL   0x64
 
#define CONTROLLER_REGISTER_DATA   0x60
 
#define CONTROLLER_COMMAND_READ_MODE   0x20
 
#define CONTROLLER_COMMAND_WRITE_MODE   0x60
 
#define CONTROLLER_COMMAND_GET_VERSION   0xA1
 
#define CONTROLLER_COMMAND_MOUSE_DISABLE   0xA7
 
#define CONTROLLER_COMMAND_MOUSE_ENABLE   0xA8
 
#define CONTROLLER_COMMAND_TEST_MOUSE   0xA9
 
#define CONTROLLER_COMMAND_SELF_TEST   0xAA
 
#define CONTROLLER_COMMAND_KEYBOARD_TEST   0xAB
 
#define CONTROLLER_COMMAND_KEYBOARD_DISABLE   0xAD
 
#define CONTROLLER_COMMAND_KEYBOARD_ENABLE   0xAE
 
#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER   0xD3
 
#define CONTROLLER_COMMAND_WRITE_MOUSE   0xD4
 
#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL   0x01
 
#define CONTROLLER_STATUS_INPUT_BUFFER_FULL   0x02
 
#define CONTROLLER_STATUS_SELF_TEST   0x04
 
#define CONTROLLER_STATUS_COMMAND   0x08
 
#define CONTROLLER_STATUS_UNLOCKED   0x10
 
#define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL   0x20
 
#define CONTROLLER_STATUS_GENERAL_TIMEOUT   0x40
 
#define CONTROLLER_STATUS_PARITY_ERROR   0x80
 
#define AUX_STATUS_OUTPUT_BUFFER_FULL
 
#define CONTROLLER_TIMEOUT   250
 

Functions

 DBG_DEFAULT_CHANNEL (HWDETECT)
 
VOID PcGetExtendedBIOSData (PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
 
static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData (UCHAR DriveNumber, ULONG *pSize)
 
static VOID DetectDockingStation (_Inout_ PCONFIGURATION_COMPONENT_DATA BusKey)
 
static VOID DetectPnpBios (PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
 
static VOID InitializeSerialPort (PUCHAR Port, UCHAR LineControl)
 
static ULONG DetectSerialMouse (PUCHAR Port)
 
static ULONG GetSerialMousePnpId (PUCHAR Port, char *Buffer)
 
static VOID DetectSerialPointerPeripheral (PCONFIGURATION_COMPONENT_DATA ControllerKey, PUCHAR Base)
 
static ULONG PcGetSerialPort (ULONG Index, PULONG Irq)
 
static ULONG GetSerialMouseDetectionBitmap (_In_opt_ PCSTR Options)
 
VOID DetectSerialPorts (_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA BusKey, _In_ GET_SERIAL_PORT MachGetSerialPort, _In_ ULONG Count)
 
static VOID DetectParallelPorts (PCONFIGURATION_COMPONENT_DATA BusKey)
 
BOOLEAN DetectKeyboardDevice (VOID)
 
static VOID DetectKeyboardPeripheral (PCONFIGURATION_COMPONENT_DATA ControllerKey)
 
static VOID DetectKeyboardController (PCONFIGURATION_COMPONENT_DATA BusKey)
 
static VOID PS2ControllerWait (VOID)
 
static BOOLEAN DetectPS2AuxPort (VOID)
 
static BOOLEAN DetectPS2AuxDevice (VOID)
 
static VOID DetectPS2Mouse (PCONFIGURATION_COMPONENT_DATA BusKey)
 
USHORT BiosIsVesaSupported (VOID)
 
BOOLEAN BiosIsVesaDdcSupported (VOID)
 
BOOLEAN BiosVesaReadEdid (VOID)
 
static VOID DetectDisplayController (PCONFIGURATION_COMPONENT_DATA BusKey)
 
static VOID DetectIsaBios (_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA SystemKey, _Out_ ULONG *BusNumber)
 
static UCHAR PcGetFloppyCount (VOID)
 
PCONFIGURATION_COMPONENT_DATA PcHwDetect (_In_opt_ PCSTR Options)
 
VOID PcHwIdle (VOID)
 
VOID __cdecl ChainLoadBiosBootSectorCode (IN UCHAR BootDrive OPTIONAL, IN ULONG BootPartition OPTIONAL)
 
VOID MachInit (const char *CmdLine)
 
VOID PcPrepareForReactOS (VOID)
 

Macro Definition Documentation

◆ AUX_STATUS_OUTPUT_BUFFER_FULL

#define AUX_STATUS_OUTPUT_BUFFER_FULL
Value:
#define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL
Definition: machpc.c:85
#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL
Definition: machpc.c:80

Definition at line 88 of file machpc.c.

◆ CONTROLLER_COMMAND_GET_VERSION

#define CONTROLLER_COMMAND_GET_VERSION   0xA1

Definition at line 68 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_DISABLE

#define CONTROLLER_COMMAND_KEYBOARD_DISABLE   0xAD

Definition at line 74 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_ENABLE

#define CONTROLLER_COMMAND_KEYBOARD_ENABLE   0xAE

Definition at line 75 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_TEST

#define CONTROLLER_COMMAND_KEYBOARD_TEST   0xAB

Definition at line 73 of file machpc.c.

◆ CONTROLLER_COMMAND_MOUSE_DISABLE

#define CONTROLLER_COMMAND_MOUSE_DISABLE   0xA7

Definition at line 69 of file machpc.c.

◆ CONTROLLER_COMMAND_MOUSE_ENABLE

#define CONTROLLER_COMMAND_MOUSE_ENABLE   0xA8

Definition at line 70 of file machpc.c.

◆ CONTROLLER_COMMAND_READ_MODE

#define CONTROLLER_COMMAND_READ_MODE   0x20

Definition at line 66 of file machpc.c.

◆ CONTROLLER_COMMAND_SELF_TEST

#define CONTROLLER_COMMAND_SELF_TEST   0xAA

Definition at line 72 of file machpc.c.

◆ CONTROLLER_COMMAND_TEST_MOUSE

#define CONTROLLER_COMMAND_TEST_MOUSE   0xA9

Definition at line 71 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MODE

#define CONTROLLER_COMMAND_WRITE_MODE   0x60

Definition at line 67 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MOUSE

#define CONTROLLER_COMMAND_WRITE_MOUSE   0xD4

Definition at line 77 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER

#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER   0xD3

Definition at line 76 of file machpc.c.

◆ CONTROLLER_REGISTER_CONTROL

#define CONTROLLER_REGISTER_CONTROL   0x64

Definition at line 62 of file machpc.c.

◆ CONTROLLER_REGISTER_DATA

#define CONTROLLER_REGISTER_DATA   0x60

Definition at line 63 of file machpc.c.

◆ CONTROLLER_REGISTER_STATUS

#define CONTROLLER_REGISTER_STATUS   0x64

Definition at line 61 of file machpc.c.

◆ CONTROLLER_STATUS_COMMAND

#define CONTROLLER_STATUS_COMMAND   0x08

Definition at line 83 of file machpc.c.

◆ CONTROLLER_STATUS_GENERAL_TIMEOUT

#define CONTROLLER_STATUS_GENERAL_TIMEOUT   0x40

Definition at line 86 of file machpc.c.

◆ CONTROLLER_STATUS_INPUT_BUFFER_FULL

#define CONTROLLER_STATUS_INPUT_BUFFER_FULL   0x02

Definition at line 81 of file machpc.c.

◆ CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL

#define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL   0x20

Definition at line 85 of file machpc.c.

◆ CONTROLLER_STATUS_OUTPUT_BUFFER_FULL

#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL   0x01

Definition at line 80 of file machpc.c.

◆ CONTROLLER_STATUS_PARITY_ERROR

#define CONTROLLER_STATUS_PARITY_ERROR   0x80

Definition at line 87 of file machpc.c.

◆ CONTROLLER_STATUS_SELF_TEST

#define CONTROLLER_STATUS_SELF_TEST   0x04

Definition at line 82 of file machpc.c.

◆ CONTROLLER_STATUS_UNLOCKED

#define CONTROLLER_STATUS_UNLOCKED   0x10

Definition at line 84 of file machpc.c.

◆ CONTROLLER_TIMEOUT

#define CONTROLLER_TIMEOUT   250

Definition at line 92 of file machpc.c.

◆ INPORT_MODE_BASE

#define INPORT_MODE_BASE   0x10

Definition at line 49 of file machpc.c.

◆ INPORT_REG_MODE

#define INPORT_REG_MODE   0x07

Definition at line 47 of file machpc.c.

◆ INPORT_REGISTER_CONTROL

#define INPORT_REGISTER_CONTROL   0x00

Definition at line 43 of file machpc.c.

◆ INPORT_REGISTER_DATA

#define INPORT_REGISTER_DATA   0x01

Definition at line 44 of file machpc.c.

◆ INPORT_REGISTER_SIGNATURE

#define INPORT_REGISTER_SIGNATURE   0x02

Definition at line 45 of file machpc.c.

◆ INPORT_RESET

#define INPORT_RESET   0x80

Definition at line 48 of file machpc.c.

◆ INPORT_SIGNATURE

#define INPORT_SIGNATURE   0xDE

Definition at line 51 of file machpc.c.

◆ INPORT_TEST_IRQ

#define INPORT_TEST_IRQ   0x16

Definition at line 50 of file machpc.c.

◆ MAX_COM_PORTS

#define MAX_COM_PORTS   4

Definition at line 29 of file machpc.c.

◆ MAX_LPT_PORTS

#define MAX_LPT_PORTS   3

Definition at line 30 of file machpc.c.

◆ MOUSE_TYPE_LOGITECH

#define MOUSE_TYPE_LOGITECH   2

Definition at line 37 of file machpc.c.

◆ MOUSE_TYPE_MICROSOFT

#define MOUSE_TYPE_MICROSOFT   1

Definition at line 35 of file machpc.c.

◆ MOUSE_TYPE_MOUSESYSTEMS

#define MOUSE_TYPE_MOUSESYSTEMS   4

Definition at line 41 of file machpc.c.

◆ MOUSE_TYPE_NONE

#define MOUSE_TYPE_NONE   0

Definition at line 33 of file machpc.c.

◆ MOUSE_TYPE_WHEELZ

#define MOUSE_TYPE_WHEELZ   3

Definition at line 39 of file machpc.c.

◆ PIC1_CONTROL_PORT

#define PIC1_CONTROL_PORT   0x20

Definition at line 53 of file machpc.c.

◆ PIC1_DATA_PORT

#define PIC1_DATA_PORT   0x21

Definition at line 54 of file machpc.c.

◆ PIC2_CONTROL_PORT

#define PIC2_CONTROL_PORT   0xA0

Definition at line 55 of file machpc.c.

◆ PIC2_DATA_PORT

#define PIC2_DATA_PORT   0xA1

Definition at line 56 of file machpc.c.

Function Documentation

◆ BiosIsVesaDdcSupported()

BOOLEAN BiosIsVesaDdcSupported ( VOID  )

Definition at line 242 of file pcvesa.c.

243{
244 REGS Regs;
245
246 TRACE("BiosIsVesaDdcSupported()\n");
247
248 Regs.w.ax = 0x4F15;
249 Regs.b.bl = 0;
250 Regs.w.cx = 0;
251 Regs.w.es = 0;
252 Regs.w.di = 0;
253 Int386(0x10, &Regs, &Regs);
254
255 TRACE("AL = 0x%x\n", Regs.b.al);
256 TRACE("AH = 0x%x\n", Regs.b.ah);
257
258 TRACE("BL = 0x%x\n", Regs.b.bl);
259
260 if (Regs.w.ax != 0x004F)
261 {
262 WARN("VBE/DDC Installation check function not supported (AL=0x%x) or failed (AH=0x%x)\n",
263 Regs.b.al, Regs.b.ah);
264 return FALSE;
265 }
266
267 return (Regs.b.ah == 0);
268}
#define WARN(fmt,...)
Definition: debug.h:115
#define FALSE
Definition: types.h:117
int __cdecl Int386(int ivec, REGS *in, REGS *out)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char bl
Definition: pcbios.h:134
unsigned char al
Definition: pcbios.h:131
unsigned char ah
Definition: pcbios.h:132
unsigned short es
Definition: pcbios.h:121
unsigned short di
Definition: pcbios.h:117
unsigned short cx
Definition: pcbios.h:113
unsigned short ax
Definition: pcbios.h:111
Definition: pcbios.h:159
BYTEREGS b
Definition: pcbios.h:163
WORDREGS w
Definition: pcbios.h:162

Referenced by DetectDisplayController().

◆ BiosIsVesaSupported()

USHORT BiosIsVesaSupported ( VOID  )

Definition at line 160 of file pcvesa.c.

161{
162 REGS Regs;
164 //USHORT* VideoModes;
165 //USHORT Index;
166
167 TRACE("BiosIsVesaSupported()\n");
168
169 RtlZeroMemory(SvgaInfo, sizeof(VESA_SVGA_INFO));
170
171 // Make sure we receive version 2.0 info
172 SvgaInfo->Signature[0] = 'V';
173 SvgaInfo->Signature[1] = 'B';
174 SvgaInfo->Signature[2] = 'E';
175 SvgaInfo->Signature[3] = '2';
176
177 // Int 10h AX=4F00h
178 // VESA SuperVGA BIOS (VBE) - GET SuperVGA INFORMATION
179 //
180 // AX = 4F00h
181 // ES:DI -> buffer for SuperVGA information (see #00077)
182 // Return:
183 // AL = 4Fh if function supported
184 // AH = status
185 // 00h successful
186 // ES:DI buffer filled
187 // 01h failed
188 // ---VBE v2.0---
189 // 02h function not supported by current hardware configuration
190 // 03h function invalid in current video mode
191 //
192 // Determine whether VESA BIOS extensions are present and the
193 // capabilities supported by the display adapter
194 //
195 // Installation check;VESA SuperVGA
196 Regs.w.ax = 0x4F00;
197 Regs.w.es = BIOSCALLBUFSEGMENT;
198 Regs.w.di = BIOSCALLBUFOFFSET;
199 Int386(0x10, &Regs, &Regs);
200
201 TRACE("AL = 0x%x\n", Regs.b.al);
202 TRACE("AH = 0x%x\n", Regs.b.ah);
203
204 if (Regs.w.ax != 0x004F)
205 {
206 WARN("VBE Get SuperVGA information function not supported (AL=0x%x) or failed (AH=0x%x)\n",
207 Regs.b.al, Regs.b.ah);
208 return 0x0000;
209 }
210
211 TRACE("Supported.\n");
212 TRACE("SvgaInfo->Signature[4] = %c%c%c%c\n", SvgaInfo->Signature[0], SvgaInfo->Signature[1], SvgaInfo->Signature[2], SvgaInfo->Signature[3]);
213 TRACE("SvgaInfo->VesaVersion = v%d.%d\n", ((SvgaInfo->VesaVersion >> 8) & 0xFF), (SvgaInfo->VesaVersion & 0xFF));
214 TRACE("SvgaInfo->OemNamePtr = 0x%x\n", SvgaInfo->OemNamePtr);
215 TRACE("SvgaInfo->Capabilities = 0x%x\n", SvgaInfo->Capabilities);
216 TRACE("SvgaInfo->VideoMemory = %dK\n", SvgaInfo->TotalVideoMemory * 64);
217 TRACE("---VBE v2.0 ---\n");
218 TRACE("SvgaInfo->OemSoftwareVersion = v%d.%d\n", ((SvgaInfo->OemSoftwareVersion >> 8) & 0x0F) + (((SvgaInfo->OemSoftwareVersion >> 12) & 0x0F) * 10), (SvgaInfo->OemSoftwareVersion & 0x0F) + (((SvgaInfo->OemSoftwareVersion >> 4) & 0x0F) * 10));
219 TRACE("SvgaInfo->VendorNamePtr = 0x%x\n", SvgaInfo->VendorNamePtr);
220 TRACE("SvgaInfo->ProductNamePtr = 0x%x\n", SvgaInfo->ProductNamePtr);
221 TRACE("SvgaInfo->ProductRevisionStringPtr = 0x%x\n", SvgaInfo->ProductRevisionStringPtr);
222 TRACE("SvgaInfo->VBE/AF Version = 0x%x (BCD WORD)\n", SvgaInfo->VBE_AF_Version);
223
224 if (SvgaInfo->Signature[0] != 'V' ||
225 SvgaInfo->Signature[1] != 'E' ||
226 SvgaInfo->Signature[2] != 'S' ||
227 SvgaInfo->Signature[3] != 'A')
228 {
229 ERR("Bad signature in VESA information (%c%c%c%c)\n",
230 SvgaInfo->Signature[0],
231 SvgaInfo->Signature[1],
232 SvgaInfo->Signature[2],
233 SvgaInfo->Signature[3]);
234 return 0x0000;
235 }
236
237 return SvgaInfo->VesaVersion;
238}
#define ERR(fmt,...)
Definition: debug.h:113
struct VESA_SVGA_INFO * PVESA_SVGA_INFO
UCHAR Signature[4]
Definition: pcvesa.c:28
USHORT VesaVersion
Definition: pcvesa.c:31
USHORT TotalVideoMemory
Definition: pcvesa.c:37
ULONG ProductNamePtr
Definition: pcvesa.c:45
ULONG VendorNamePtr
Definition: pcvesa.c:44
ULONG Capabilities
Definition: pcvesa.c:34
USHORT OemSoftwareVersion
Definition: pcvesa.c:43
ULONG OemNamePtr
Definition: pcvesa.c:32
ULONG ProductRevisionStringPtr
Definition: pcvesa.c:46
USHORT VBE_AF_Version
Definition: pcvesa.c:47
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define BIOSCALLBUFSEGMENT
Definition: x86common.h:21
#define BIOSCALLBUFOFFSET
Definition: x86common.h:22
#define BIOSCALLBUFFER
Definition: x86common.h:12

Referenced by DetectDisplayController().

◆ BiosVesaReadEdid()

BOOLEAN BiosVesaReadEdid ( VOID  )

Definition at line 272 of file pcvesa.c.

273{
274 REGS Regs;
275
276 TRACE("BiosVesaReadEdid()\n");
277
279
280 Regs.w.ax = 0x4F15;
281 Regs.b.bl = 1;
282 Regs.w.cx = 0;
283 Regs.w.dx = 0;
284 Regs.w.es = BIOSCALLBUFSEGMENT;
285 Regs.w.di = BIOSCALLBUFOFFSET;
286 Int386(0x10, &Regs, &Regs);
287
288 TRACE("AL = 0x%x\n", Regs.b.al);
289 TRACE("AH = 0x%x\n", Regs.b.ah);
290
291 if (Regs.w.ax != 0x004F)
292 {
293 WARN("VBE/DDC Read EDID function not supported (AL=0x%x) or failed (AH=0x%x)\n",
294 Regs.b.al, Regs.b.ah);
295 return FALSE;
296 }
297
298 return (Regs.b.ah == 0);
299}
unsigned short dx
Definition: pcbios.h:114

Referenced by DetectDisplayController().

◆ ChainLoadBiosBootSectorCode()

VOID __cdecl ChainLoadBiosBootSectorCode ( IN UCHAR BootDrive  OPTIONAL,
IN ULONG BootPartition  OPTIONAL 
)

Definition at line 1745 of file machpc.c.

1748{
1749 REGS Regs;
1750
1751 RtlZeroMemory(&Regs, sizeof(Regs));
1752
1753 /* Set the boot drive and the boot partition */
1754 Regs.b.dl = (UCHAR)(BootDrive ? BootDrive : FrldrBootDrive);
1755 Regs.b.dh = (UCHAR)(BootPartition ? BootPartition : FrldrBootPartition);
1756
1757 /*
1758 * Don't stop the floppy drive motor when we are just booting a bootsector,
1759 * a drive, or a partition. If we were to stop the floppy motor, the BIOS
1760 * wouldn't be informed and if the next read is to a floppy then the BIOS
1761 * will still think the motor is on and this will result in a read error.
1762 */
1763 // DiskStopFloppyMotor();
1764
1765 Relocator16Boot(&Regs,
1766 /* Stack segment:pointer */
1767 0x0000, 0x7C00,
1768 /* Code segment:pointer */
1769 0x0000, 0x7C00);
1770}
VOID __cdecl Relocator16Boot(IN REGS *In, IN USHORT StackSegment, IN USHORT StackPointer, IN USHORT CodeSegment, IN USHORT CodePointer)
unsigned char dl
Definition: pcbios.h:140
unsigned char dh
Definition: pcbios.h:141
UCHAR FrldrBootDrive
Definition: uefidisk.c:47
ULONG FrldrBootPartition
Definition: uefidisk.c:48
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( HWDETECT  )

◆ DetectDisplayController()

static VOID DetectDisplayController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1570 of file machpc.c.

1571{
1573 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1574 USHORT VesaVersion;
1575
1576 /* FIXME: Set 'ComponentInformation' value */
1577
1578 VesaVersion = BiosIsVesaSupported();
1579 if (VesaVersion != 0)
1580 {
1581 TRACE("VESA version %c.%c\n",
1582 (VesaVersion >> 8) + '0',
1583 (VesaVersion & 0xFF) + '0');
1584 }
1585 else
1586 {
1587 TRACE("VESA not supported\n");
1588 }
1589
1590 if (VesaVersion >= 0x0200)
1591 Identifier = "VBE Display";
1592 else
1593 Identifier = "VGA Display";
1594
1599 0,
1600 0xFFFFFFFF,
1601 Identifier,
1602 NULL,
1603 0,
1604 &ControllerKey);
1605
1606 /* FIXME: Add display peripheral (monitor) data */
1607 if (VesaVersion != 0)
1608 {
1610 {
1611 TRACE("VESA/DDC supported!\n");
1612 if (BiosVesaReadEdid())
1613 {
1614 TRACE("EDID data read successfully!\n");
1615 }
1616 }
1617 }
1618}
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 NULL
Definition: types.h:112
BOOLEAN BiosVesaReadEdid(VOID)
Definition: pcvesa.c:272
BOOLEAN BiosIsVesaDdcSupported(VOID)
Definition: pcvesa.c:242
USHORT BiosIsVesaSupported(VOID)
Definition: pcvesa.c:160
unsigned short USHORT
Definition: pedump.c:61
@ ControllerClass
Definition: arc.h:94
@ DisplayController
Definition: arc.h:123
@ ConsoleOut
Definition: arc.h:83
@ Output
Definition: arc.h:85
const char * PCSTR
Definition: typedefs.h:52

Referenced by DetectIsaBios().

◆ DetectDockingStation()

static VOID DetectDockingStation ( _Inout_ PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 198 of file machpc.c.

200{
201 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
202 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
203 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
204 PDOCKING_STATE_INFORMATION DockingState;
206
208
209 /* Build full device descriptor */
212 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
213 if (PartialResourceList == NULL)
214 {
215 ERR("Failed to allocate resource descriptor\n");
216 return;
217 }
218
219 /* Initialize resource descriptor */
220 RtlZeroMemory(PartialResourceList, Size);
221 PartialResourceList->Version = 0;
222 PartialResourceList->Revision = 0;
223 PartialResourceList->Count = 1;
224
225 /* Set device specific data */
226 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
227 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
229 PartialDescriptor->Flags = 0;
230 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(DOCKING_STATE_INFORMATION);
231
232 DockingState = (PDOCKING_STATE_INFORMATION)&PartialResourceList->PartialDescriptors[1];
233 DockingState->ReturnCode = Result;
234 if (Result == 0)
235 {
236 /* FIXME: Add more device specific data */
237 ERR("FIXME: System docked\n");
238 }
239
240 /* Create controller key */
244 0,
245 0,
246 0xFFFFFFFF,
247 "Docking State Information",
248 PartialResourceList,
249 Size,
250 &PeripheralKey);
251}
#define DiskReadBuffer
Definition: hardware.h:33
ULONG __cdecl PnpBiosGetDockStationInformation(UCHAR *DockingStationInfo)
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:174
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
if(dx< 0)
Definition: linetemp.h:194
struct _DOCKING_STATE_INFORMATION DOCKING_STATE_INFORMATION
struct _DOCKING_STATE_INFORMATION * PDOCKING_STATE_INFORMATION
@ PeripheralClass
Definition: arc.h:95
@ DockingInformation
Definition: arc.h:142
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@395::@404 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@395 u
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
uint32_t ULONG
Definition: typedefs.h:59
#define TAG_HW_RESOURCE_LIST
Definition: uefidisk.c:15
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_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
@ CmResourceShareUndetermined
Definition: cmtypes.h:240

Referenced by DetectPnpBios().

◆ DetectIsaBios()

static VOID DetectIsaBios ( _In_opt_ PCSTR  Options,
_Inout_ PCONFIGURATION_COMPONENT_DATA  SystemKey,
_Out_ ULONG BusNumber 
)
static

Definition at line 1622 of file machpc.c.

1626{
1627 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1629 ULONG Size;
1630
1631 /* Set 'Configuration Data' value */
1632 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1634 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1635 if (PartialResourceList == NULL)
1636 {
1637 ERR("Failed to allocate resource descriptor\n");
1638 return;
1639 }
1640
1641 /* Initialize resource descriptor */
1642 RtlZeroMemory(PartialResourceList, Size);
1643 PartialResourceList->Version = 1;
1644 PartialResourceList->Revision = 1;
1645 PartialResourceList->Count = 0;
1646
1647 /* Create new bus key */
1648 FldrCreateComponentKey(SystemKey,
1651 0,
1652 0,
1653 0xFFFFFFFF,
1654 "ISA",
1655 PartialResourceList,
1656 Size,
1657 &BusKey);
1658
1659 /* Increment bus number */
1660 (*BusNumber)++;
1661
1662 /* Detect ISA/BIOS devices */
1663 DetectBiosDisks(SystemKey, BusKey);
1665 DetectParallelPorts(BusKey);
1667 DetectPS2Mouse(BusKey);
1668#if defined(_M_IX86)
1669 DetectBusMouse(BusKey);
1670#endif
1672
1673 /* FIXME: Detect more ISA devices */
1674}
static ULONG PcGetSerialPort(ULONG Index, PULONG Irq)
Definition: machpc.c:717
#define MAX_COM_PORTS
Definition: machpc.c:29
static VOID DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1111
static VOID DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1288
static VOID DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:885
VOID DetectSerialPorts(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA BusKey, _In_ GET_SERIAL_PORT MachGetSerialPort, _In_ ULONG Count)
Definition: machpc.c:782
static VOID DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1570
VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pchw.c:344
@ AdapterClass
Definition: arc.h:93
@ MultiFunctionAdapter
Definition: arc.h:116
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534

Referenced by PcHwDetect().

◆ DetectKeyboardController()

static VOID DetectKeyboardController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1111 of file machpc.c.

1112{
1113 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1114 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
1115 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1116 ULONG Size;
1117
1118 /* Set 'Configuration Data' value */
1119 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
1121 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1122 if (PartialResourceList == NULL)
1123 {
1124 ERR("Failed to allocate resource descriptor\n");
1125 return;
1126 }
1127
1128 /* Initialize resource descriptor */
1129 RtlZeroMemory(PartialResourceList, Size);
1130 PartialResourceList->Version = 1;
1131 PartialResourceList->Revision = 1;
1132 PartialResourceList->Count = 3;
1133
1134 /* Set Interrupt */
1135 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1136 PartialDescriptor->Type = CmResourceTypeInterrupt;
1137 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1138 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1139 PartialDescriptor->u.Interrupt.Level = 1;
1140 PartialDescriptor->u.Interrupt.Vector = 1;
1141 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
1142
1143 /* Set IO Port 0x60 */
1144 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
1145 PartialDescriptor->Type = CmResourceTypePort;
1147 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1148 PartialDescriptor->u.Port.Start.LowPart = 0x60;
1149 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1150 PartialDescriptor->u.Port.Length = 1;
1151
1152 /* Set IO Port 0x64 */
1153 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
1154 PartialDescriptor->Type = CmResourceTypePort;
1156 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1157 PartialDescriptor->u.Port.Start.LowPart = 0x64;
1158 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1159 PartialDescriptor->u.Port.Length = 1;
1160
1161 /* Create controller key */
1165 Input | ConsoleIn,
1166 0,
1167 0xFFFFFFFF,
1168 NULL,
1169 PartialResourceList,
1170 Size,
1171 &ControllerKey);
1172
1173 DetectKeyboardPeripheral(ControllerKey);
1174}
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
static VOID DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: machpc.c:1046
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
@ KeyboardController
Definition: arc.h:126
@ ConsoleIn
Definition: arc.h:82
@ Input
Definition: arc.h:84
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@395::@398 Interrupt
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@395::@397 Port
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241

Referenced by DetectIsaBios().

◆ DetectKeyboardDevice()

BOOLEAN DetectKeyboardDevice ( VOID  )

Definition at line 977 of file machpc.c.

978{
980 UCHAR Scancode;
981 ULONG Loops;
983
984 /* Identify device */
986
987 /* Wait for reply */
988 for (Loops = 0; Loops < 100; Loops++)
989 {
993 break;
994 }
995
997 {
998 /* PC/XT keyboard or no keyboard */
999 Result = FALSE;
1000 }
1001
1003 if (Scancode != 0xFA)
1004 {
1005 /* No ACK received */
1006 Result = FALSE;
1007 }
1008
1010
1013 {
1014 /* Found AT keyboard */
1015 return Result;
1016 }
1017
1019 if (Scancode != 0xAB)
1020 {
1021 /* No 0xAB received */
1022 Result = FALSE;
1023 }
1024
1026
1029 {
1030 /* No byte in buffer */
1031 Result = FALSE;
1032 }
1033
1035 if (Scancode != 0x41)
1036 {
1037 /* No 0x41 received */
1038 Result = FALSE;
1039 }
1040
1041 /* Found MF-II keyboard */
1042 return Result;
1043}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
Status
Definition: gdiplustypes.h:25
#define CONTROLLER_REGISTER_STATUS
Definition: machpc.c:61
#define CONTROLLER_REGISTER_DATA
Definition: machpc.c:63
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
VOID StallExecutionProcessor(ULONG Microseconds)
Definition: pchw.c:60
unsigned char * PUCHAR
Definition: typedefs.h:53

◆ DetectKeyboardPeripheral()

static VOID DetectKeyboardPeripheral ( PCONFIGURATION_COMPONENT_DATA  ControllerKey)
static

Definition at line 1046 of file machpc.c.

1047{
1048 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1049 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
1050 PCM_KEYBOARD_DEVICE_DATA KeyboardData;
1051 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
1052 ULONG Size;
1053 REGS Regs;
1054
1055 /* HACK: don't call DetectKeyboardDevice() as it fails in Qemu 0.8.2
1056 if (DetectKeyboardDevice()) */
1057 {
1058 /* Set 'Configuration Data' value */
1059 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
1061 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1062 if (PartialResourceList == NULL)
1063 {
1064 ERR("Failed to allocate resource descriptor\n");
1065 return;
1066 }
1067
1068 /* Initialize resource descriptor */
1069 RtlZeroMemory(PartialResourceList, Size);
1070 PartialResourceList->Version = 1;
1071 PartialResourceList->Revision = 1;
1072 PartialResourceList->Count = 1;
1073
1074 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1075 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
1076 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1077 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_KEYBOARD_DEVICE_DATA);
1078
1079 /* Int 16h AH=02h
1080 * KEYBOARD - GET SHIFT FLAGS
1081 *
1082 * Return:
1083 * AL - shift flags
1084 */
1085 Regs.b.ah = 0x02;
1086 Int386(0x16, &Regs, &Regs);
1087
1088 KeyboardData = (PCM_KEYBOARD_DEVICE_DATA)(PartialDescriptor + 1);
1089 KeyboardData->Version = 1;
1090 KeyboardData->Revision = 1;
1091 KeyboardData->Type = 4;
1092 KeyboardData->Subtype = 0;
1093 KeyboardData->KeyboardFlags = Regs.b.al;
1094
1095 /* Create controller key */
1096 FldrCreateComponentKey(ControllerKey,
1099 Input | ConsoleIn,
1100 0,
1101 0xFFFFFFFF,
1102 "PCAT_ENHANCED",
1103 PartialResourceList,
1104 Size,
1105 &PeripheralKey);
1106 }
1107}
@ KeyboardPeripheral
Definition: arc.h:136
struct _CM_KEYBOARD_DEVICE_DATA * PCM_KEYBOARD_DEVICE_DATA
struct _CM_KEYBOARD_DEVICE_DATA CM_KEYBOARD_DEVICE_DATA

Referenced by DetectKeyboardController().

◆ DetectParallelPorts()

static VOID DetectParallelPorts ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 885 of file machpc.c.

886{
887 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
888 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
889 ULONG Irq[MAX_LPT_PORTS] = {7, 5, (ULONG) - 1};
890 CHAR Identifier[80];
891 PCONFIGURATION_COMPONENT_DATA ControllerKey;
892 PUSHORT BasePtr;
893 ULONG Base;
894 ULONG ControllerNumber = 0;
895 ULONG i;
896 ULONG Size;
897
898 TRACE("DetectParallelPorts() called\n");
899
900 /*
901 * The BIOS data area 0x408 holds the address of the first valid LPT port.
902 * Each LPT port address is stored in a 2-byte field.
903 * Infos at: http://www.bioscentral.com/misc/bda.htm
904 */
905 BasePtr = (PUSHORT)0x408;
906
907 for (i = 0; i < MAX_LPT_PORTS; i++, BasePtr++)
908 {
909 Base = (ULONG) * BasePtr;
910 if (Base == 0)
911 continue;
912
913 TRACE("Parallel port %u: %x\n", ControllerNumber, Base);
914
915 /* Set 'Identifier' value */
916 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "PARALLEL%ld", i + 1);
917
918 /* Build full device descriptor */
920 if (Irq[i] != (ULONG) - 1)
922
923 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
924 if (PartialResourceList == NULL)
925 {
926 ERR("Failed to allocate resource descriptor! Ignoring remaining parallel ports. (i = %lu)\n", i);
927 break;
928 }
929
930 /* Initialize resource descriptor */
931 RtlZeroMemory(PartialResourceList, Size);
932 PartialResourceList->Version = 1;
933 PartialResourceList->Revision = 1;
934 PartialResourceList->Count = (Irq[i] != (ULONG) - 1) ? 2 : 1;
935
936 /* Set IO Port */
937 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
938 PartialDescriptor->Type = CmResourceTypePort;
940 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
941 PartialDescriptor->u.Port.Start.LowPart = Base;
942 PartialDescriptor->u.Port.Start.HighPart = 0x0;
943 PartialDescriptor->u.Port.Length = 3;
944
945 /* Set Interrupt */
946 if (Irq[i] != (ULONG) - 1)
947 {
948 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
949 PartialDescriptor->Type = CmResourceTypeInterrupt;
951 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
952 PartialDescriptor->u.Interrupt.Level = Irq[i];
953 PartialDescriptor->u.Interrupt.Vector = Irq[i];
954 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
955 }
956
957 /* Create controller key */
961 Output,
962 ControllerNumber,
963 0xFFFFFFFF,
965 PartialResourceList,
966 Size,
967 &ControllerKey);
968
969 ControllerNumber++;
970 }
971
972 TRACE("DetectParallelPorts() done\n");
973}
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
#define MAX_LPT_PORTS
Definition: machpc.c:30
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2439
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
@ ParallelController
Definition: arc.h:124
uint16_t * PUSHORT
Definition: typedefs.h:56
char CHAR
Definition: xmlstorage.h:175

Referenced by DetectIsaBios().

◆ DetectPnpBios()

static VOID DetectPnpBios ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
ULONG BusNumber 
)
static

Definition at line 255 of file machpc.c.

256{
257 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
261 ULONG x;
262 ULONG NodeSize = 0;
263 ULONG NodeCount = 0;
265 ULONG FoundNodeCount;
266 int i;
267 ULONG PnpBufferSize;
268 ULONG PnpBufferSizeLimit;
269 ULONG Size;
270 char *Ptr;
271
273 if (InstData == NULL || strncmp((CHAR*)InstData->Signature, "$PnP", 4))
274 {
275 TRACE("PnP-BIOS not supported\n");
276 return;
277 }
278
279 TRACE("PnP-BIOS supported\n");
280 TRACE("Signature '%c%c%c%c'\n",
281 InstData->Signature[0], InstData->Signature[1],
282 InstData->Signature[2], InstData->Signature[3]);
283
284 x = PnpBiosGetDeviceNodeCount(&NodeSize, &NodeCount);
285 if (x == 0x82)
286 {
287 TRACE("PnP-BIOS function 'Get Number of System Device Nodes' not supported\n");
288 return;
289 }
290
291 NodeCount &= 0xFF; // needed since some fscked up BIOSes return
292 // wrong info (e.g. Mac Virtual PC)
293 // e.g. look: http://my.execpc.com/~geezer/osd/pnp/pnp16.c
294 if (x != 0 || NodeSize == 0 || NodeCount == 0)
295 {
296 ERR("PnP-BIOS failed to enumerate device nodes\n");
297 return;
298 }
299 TRACE("MaxNodeSize %u NodeCount %u\n", NodeSize, NodeCount);
300 TRACE("Estimated buffer size %u\n", NodeSize * NodeCount);
301
302 /* Set 'Configuration Data' value */
303 PnpBufferSizeLimit = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK)
304 + (NodeSize * NodeCount);
305 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) + PnpBufferSizeLimit;
306 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
307 if (PartialResourceList == NULL)
308 {
309 ERR("Failed to allocate resource descriptor\n");
310 return;
311 }
312
313 /* Initialize resource descriptor */
314 RtlZeroMemory(PartialResourceList, Size);
315 PartialResourceList->Version = 1;
316 PartialResourceList->Revision = 1;
317 PartialResourceList->Count = 1;
318 PartialResourceList->PartialDescriptors[0].Type =
320 PartialResourceList->PartialDescriptors[0].ShareDisposition =
322
323 /* The buffer starts after PartialResourceList->PartialDescriptors[0] */
324 Ptr = (char *)(PartialResourceList + 1);
325
326 /* Set installation check data */
327 memcpy (Ptr, InstData, sizeof(CM_PNP_BIOS_INSTALLATION_CHECK));
329 PnpBufferSize = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK);
330
331 /* Copy device nodes */
332 FoundNodeCount = 0;
333 for (i = 0; i < 0xFF; i++)
334 {
335 NodeNumber = (UCHAR)i;
336
338 if (x == 0)
339 {
341
342 TRACE("Node: %u Size %u (0x%x)\n",
343 DeviceNode->Node,
344 DeviceNode->Size,
345 DeviceNode->Size);
346
347 if (PnpBufferSize + DeviceNode->Size > PnpBufferSizeLimit)
348 {
349 ERR("Buffer too small! Ignoring remaining device nodes. (i = %d)\n", i);
350 break;
351 }
352
354
355 Ptr += DeviceNode->Size;
356 PnpBufferSize += DeviceNode->Size;
357
358 FoundNodeCount++;
359 if (FoundNodeCount >= NodeCount)
360 break;
361 }
362 }
363
364 /* Set real data size */
365 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
366 PnpBufferSize;
367 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) + PnpBufferSize;
368
369 TRACE("Real buffer size: %u\n", PnpBufferSize);
370 TRACE("Resource size: %u\n", Size);
371
372 /* Create component key */
373 FldrCreateComponentKey(SystemKey,
376 0,
377 0,
378 0xFFFFFFFF,
379 "PNP BIOS",
380 PartialResourceList,
381 Size,
382 &BusKey);
383
384 DetectDockingStation(BusKey);
385
386 (*BusNumber)++;
387}
@ DeviceNode
Definition: Node.h:9
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
ULONG __cdecl PnpBiosGetDeviceNode(UCHAR *NodeId, UCHAR *NodeBuffer)
ULONG __cdecl PnpBiosGetDeviceNodeCount(ULONG *NodeSize, ULONG *NodeCount)
ULONG_PTR __cdecl PnpBiosSupported(VOID)
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static VOID DetectDockingStation(_Inout_ PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:198
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _CM_PNP_BIOS_INSTALLATION_CHECK * PCM_PNP_BIOS_INSTALLATION_CHECK
struct _CM_PNP_BIOS_INSTALLATION_CHECK CM_PNP_BIOS_INSTALLATION_CHECK
struct _CM_PNP_BIOS_DEVICE_NODE * PCM_PNP_BIOS_DEVICE_NODE
_Out_ PUSHORT NodeNumber
Definition: iofuncs.h:2574

Referenced by PcHwDetect().

◆ DetectPS2AuxDevice()

static BOOLEAN DetectPS2AuxDevice ( VOID  )
static

Definition at line 1239 of file machpc.c.

1240{
1241 UCHAR Scancode;
1242 UCHAR Status;
1243 ULONG Loops;
1245
1250
1251 /* Identify device */
1253
1254 /* Wait for reply */
1255 for (Loops = 0; Loops < 100; Loops++)
1256 {
1260 break;
1261 }
1262
1265 Result = FALSE;
1266
1268 if (Scancode != 0xFA)
1269 Result = FALSE;
1270
1272
1275 Result = FALSE;
1276
1278 if (Scancode != 0x00)
1279 Result = FALSE;
1280
1281 return Result;
1282}
#define CONTROLLER_COMMAND_WRITE_MOUSE
Definition: machpc.c:77
static VOID PS2ControllerWait(VOID)
Definition: machpc.c:1178
#define CONTROLLER_REGISTER_CONTROL
Definition: machpc.c:62

Referenced by DetectPS2Mouse().

◆ DetectPS2AuxPort()

static BOOLEAN DetectPS2AuxPort ( VOID  )
static

Definition at line 1196 of file machpc.c.

1197{
1198#if 1
1199 /* Current detection is too unreliable. Just do as if
1200 * the PS/2 aux port is always present
1201 */
1202 return TRUE;
1203#else
1204 ULONG Loops;
1205 UCHAR Status;
1206
1207 /* Put the value 0x5A in the output buffer using the
1208 * "WriteAuxiliary Device Output Buffer" command (0xD3).
1209 * Poll the Status Register for a while to see if the value really turns up
1210 * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1211 * to 1 in the Status Register, we assume this controller has an
1212 * Auxiliary Port (a.k.a. Mouse Port).
1213 */
1218
1219 /* 0x5A is a random dummy value */
1221 0x5A);
1222
1223 for (Loops = 0; Loops < 10; Loops++)
1224 {
1228 break;
1229 }
1230
1232
1234#endif
1235}
#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER
Definition: machpc.c:76

Referenced by DetectPS2Mouse().

◆ DetectPS2Mouse()

static VOID DetectPS2Mouse ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1288 of file machpc.c.

1289{
1290 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1291 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1292 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
1293 ULONG Size;
1294
1295 if (DetectPS2AuxPort())
1296 {
1297 TRACE("Detected PS2 port\n");
1298
1299 PartialResourceList = FrLdrHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST), TAG_HW_RESOURCE_LIST);
1300 if (PartialResourceList == NULL)
1301 {
1302 ERR("Failed to allocate resource descriptor\n");
1303 return;
1304 }
1305
1306 /* Initialize resource descriptor */
1307 RtlZeroMemory(PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST));
1308 PartialResourceList->Version = 1;
1309 PartialResourceList->Revision = 1;
1310 PartialResourceList->Count = 1;
1311
1312 /* Set Interrupt */
1313 PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeInterrupt;
1315 PartialResourceList->PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1316 PartialResourceList->PartialDescriptors[0].u.Interrupt.Level = 12;
1317 PartialResourceList->PartialDescriptors[0].u.Interrupt.Vector = 12;
1318 PartialResourceList->PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF;
1319
1320 /* Create controller key */
1324 Input,
1325 0,
1326 0xFFFFFFFF,
1327 NULL,
1328 PartialResourceList,
1330 &ControllerKey);
1331
1332 if (DetectPS2AuxDevice())
1333 {
1334 TRACE("Detected PS2 mouse\n");
1335
1336 /* Initialize resource descriptor */
1337 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1339 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1340 if (PartialResourceList == NULL)
1341 {
1342 ERR("Failed to allocate resource descriptor\n");
1343 return;
1344 }
1345
1346 RtlZeroMemory(PartialResourceList, Size);
1347 PartialResourceList->Version = 1;
1348 PartialResourceList->Revision = 1;
1349 PartialResourceList->Count = 0;
1350
1351 /* Create peripheral key */
1352 FldrCreateComponentKey(ControllerKey,
1355 Input,
1356 0,
1357 0xFFFFFFFF,
1358 "MICROSOFT PS2 MOUSE",
1359 PartialResourceList,
1360 Size,
1361 &PeripheralKey);
1362 }
1363 }
1364}
static BOOLEAN DetectPS2AuxDevice(VOID)
Definition: machpc.c:1239
static BOOLEAN DetectPS2AuxPort(VOID)
Definition: machpc.c:1196
@ PointerController
Definition: arc.h:125
@ PointerPeripheral
Definition: arc.h:135

Referenced by DetectIsaBios().

◆ DetectSerialMouse()

static ULONG DetectSerialMouse ( PUCHAR  Port)
static

Definition at line 405 of file machpc.c.

406{
407 CHAR Buffer[4];
408 ULONG i;
409 ULONG TimeOut;
410 UCHAR LineControl;
411
412 /* Shutdown mouse or something like that */
413 LineControl = READ_PORT_UCHAR(Port + 4);
414 WRITE_PORT_UCHAR(Port + 4, (LineControl & ~0x02) | 0x01);
416
417 /*
418 * Clear buffer
419 * Maybe there is no serial port although BIOS reported one (this
420 * is the case on Apple hardware), or the serial port is misbehaving,
421 * therefore we must give up after some time.
422 */
423 TimeOut = 200;
424 while (READ_PORT_UCHAR(Port + 5) & 0x01)
425 {
426 if (--TimeOut == 0)
427 return MOUSE_TYPE_NONE;
429 }
430
431 /*
432 * Send modem control with 'Data Terminal Ready', 'Request To Send' and
433 * 'Output Line 2' message. This enables mouse to identify.
434 */
435 WRITE_PORT_UCHAR(Port + 4, 0x0b);
436
437 /* Wait 10 milliseconds for the mouse getting ready */
439
440 /* Read first four bytes, which contains Microsoft Mouse signs */
441 TimeOut = 20;
442 for (i = 0; i < 4; i++)
443 {
444 while ((READ_PORT_UCHAR(Port + 5) & 1) == 0)
445 {
447 --TimeOut;
448 if (TimeOut == 0)
449 return MOUSE_TYPE_NONE;
450 }
452 }
453
454 TRACE("Mouse data: %x %x %x %x\n",
455 Buffer[0], Buffer[1], Buffer[2], Buffer[3]);
456
457 /* Check that four bytes for signs */
458 for (i = 0; i < 4; ++i)
459 {
460 if (Buffer[i] == 'B')
461 {
462 /* Sign for Microsoft Ballpoint */
463// DbgPrint("Microsoft Ballpoint device detected\n");
464// DbgPrint("THIS DEVICE IS NOT SUPPORTED, YET\n");
465 return MOUSE_TYPE_NONE;
466 }
467 else if (Buffer[i] == 'M')
468 {
469 /* Sign for Microsoft Mouse protocol followed by button specifier */
470 if (i == 3)
471 {
472 /* Overflow Error */
473 return MOUSE_TYPE_NONE;
474 }
475
476 switch (Buffer[i + 1])
477 {
478 case '3':
479 TRACE("Microsoft Mouse with 3-buttons detected\n");
480 return MOUSE_TYPE_LOGITECH;
481
482 case 'Z':
483 TRACE("Microsoft Wheel Mouse detected\n");
484 return MOUSE_TYPE_WHEELZ;
485
486 /* case '2': */
487 default:
488 TRACE("Microsoft Mouse with 2-buttons detected\n");
490 }
491 }
492 }
493
494 return MOUSE_TYPE_NONE;
495}
Definition: bufpool.h:45
CPPORT Port[4]
Definition: headless.c:35
#define MOUSE_TYPE_MICROSOFT
Definition: machpc.c:35
#define MOUSE_TYPE_LOGITECH
Definition: machpc.c:37
#define MOUSE_TYPE_NONE
Definition: machpc.c:33
#define MOUSE_TYPE_WHEELZ
Definition: machpc.c:39

Referenced by DetectSerialPointerPeripheral().

◆ DetectSerialPointerPeripheral()

static VOID DetectSerialPointerPeripheral ( PCONFIGURATION_COMPONENT_DATA  ControllerKey,
PUCHAR  Base 
)
static

Definition at line 558 of file machpc.c.

560{
561 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
562 char Buffer[256];
563 CHAR Identifier[256];
564 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
565 ULONG MouseType;
567 ULONG i;
568 ULONG j;
569 ULONG k;
570
571 TRACE("DetectSerialPointerPeripheral()\n");
572
573 Identifier[0] = 0;
574
576 MouseType = DetectSerialMouse(Base);
577
578 if (MouseType != MOUSE_TYPE_NONE)
579 {
581 TRACE( "PnP ID length: %u\n", Length);
582
583 if (Length != 0)
584 {
585 /* Convert PnP sting to ASCII */
586 if (Buffer[0] == 0x08)
587 {
588 for (i = 0; i < Length; i++)
589 Buffer[i] += 0x20;
590 }
591 Buffer[Length] = 0;
592
593 TRACE("PnP ID string: %s\n", Buffer);
594
595 /* Copy PnpId string */
596 for (i = 0; i < 7; i++)
597 {
598 Identifier[i] = Buffer[3 + i];
599 }
600 memcpy(&Identifier[7],
601 L" - ",
602 3 * sizeof(WCHAR));
603
604 /* Skip device serial number */
605 i = 10;
606 if (Buffer[i] == '\\')
607 {
608 for (j = ++i; i < Length; ++i)
609 {
610 if (Buffer[i] == '\\')
611 break;
612 }
613 if (i >= Length)
614 i -= 3;
615 }
616
617 /* Skip PnP class */
618 if (Buffer[i] == '\\')
619 {
620 for (j = ++i; i < Length; ++i)
621 {
622 if (Buffer[i] == '\\')
623 break;
624 }
625
626 if (i >= Length)
627 i -= 3;
628 }
629
630 /* Skip compatible PnP Id */
631 if (Buffer[i] == '\\')
632 {
633 for (j = ++i; i < Length; ++i)
634 {
635 if (Buffer[i] == '\\')
636 break;
637 }
638 if (Buffer[j] == '*')
639 ++j;
640 if (i >= Length)
641 i -= 3;
642 }
643
644 /* Get product description */
645 if (Buffer[i] == '\\')
646 {
647 for (j = ++i; i < Length; ++i)
648 {
649 if (Buffer[i] == ';')
650 break;
651 }
652 if (i >= Length)
653 i -= 3;
654 if (i > j + 1)
655 {
656 for (k = 0; k < i - j; k++)
657 {
658 Identifier[k + 10] = Buffer[k + j];
659 }
660 Identifier[10 + (i - j)] = 0;
661 }
662 }
663
664 TRACE("Identifier string: %s\n", Identifier);
665 }
666
667 if (Length == 0 || strlen(Identifier) < 11)
668 {
669 switch (MouseType)
670 {
672 strcpy(Identifier, "LOGITECH SERIAL MOUSE");
673 break;
674
676 strcpy(Identifier, "MICROSOFT SERIAL MOUSE WITH WHEEL");
677 break;
678
680 default:
681 strcpy(Identifier, "MICROSOFT SERIAL MOUSE");
682 break;
683 }
684 }
685
686 /* Set 'Configuration Data' value */
689 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
690 if (PartialResourceList == NULL)
691 {
692 ERR("Failed to allocate resource descriptor\n");
693 return;
694 }
695
696 RtlZeroMemory(PartialResourceList, Size);
697 PartialResourceList->Version = 1;
698 PartialResourceList->Revision = 1;
699 PartialResourceList->Count = 0;
700
701 /* Create 'PointerPeripheral' key */
702 FldrCreateComponentKey(ControllerKey,
705 Input,
706 0,
707 0xFFFFFFFF,
709 PartialResourceList,
710 Size,
711 &PeripheralKey);
712 }
713}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
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
static ULONG GetSerialMousePnpId(PUCHAR Port, char *Buffer)
Definition: machpc.c:498
static ULONG DetectSerialMouse(PUCHAR Port)
Definition: machpc.c:405
static VOID InitializeSerialPort(PUCHAR Port, UCHAR LineControl)
Definition: machpc.c:391
int k
Definition: mpi.c:3369
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DetectSerialPorts().

◆ DetectSerialPorts()

VOID DetectSerialPorts ( _In_opt_ PCSTR  Options,
_Inout_ PCONFIGURATION_COMPONENT_DATA  BusKey,
_In_ GET_SERIAL_PORT  MachGetSerialPort,
_In_ ULONG  Count 
)

Definition at line 782 of file machpc.c.

787{
788 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
789 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
790 PCM_SERIAL_DEVICE_DATA SerialDeviceData;
791 ULONG Irq;
792 ULONG Base;
793 CHAR Identifier[80];
794 ULONG ControllerNumber = 0;
795 PCONFIGURATION_COMPONENT_DATA ControllerKey;
796 ULONG i;
797 ULONG Size;
798 ULONG PortBitmap;
799
800 TRACE("DetectSerialPorts()\n");
801
803
804 for (i = 0; i < Count; i++)
805 {
806 Base = MachGetSerialPort(i, &Irq);
807 if ((Base == 0) || !CpDoesPortExist(UlongToPtr(Base)))
808 continue;
809
810 TRACE("Found COM%u port at 0x%x\n", i + 1, Base);
811
812 /* Set 'Identifier' value */
813 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "COM%ld", i + 1);
814
815 /* Build full device descriptor */
818 sizeof(CM_SERIAL_DEVICE_DATA);
819 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
820 if (PartialResourceList == NULL)
821 {
822 ERR("Failed to allocate resource descriptor! Ignoring remaining serial ports. (i = %lu, Count = %lu)\n",
823 i, Count);
824 break;
825 }
826
827 /* Initialize resource descriptor */
828 RtlZeroMemory(PartialResourceList, Size);
829 PartialResourceList->Version = 1;
830 PartialResourceList->Revision = 1;
831 PartialResourceList->Count = 3;
832
833 /* Set IO Port */
834 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
835 PartialDescriptor->Type = CmResourceTypePort;
837 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
838 PartialDescriptor->u.Port.Start.LowPart = Base;
839 PartialDescriptor->u.Port.Start.HighPart = 0x0;
840 PartialDescriptor->u.Port.Length = 8;
841
842 /* Set Interrupt */
843 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
844 PartialDescriptor->Type = CmResourceTypeInterrupt;
846 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
847 PartialDescriptor->u.Interrupt.Level = Irq;
848 PartialDescriptor->u.Interrupt.Vector = Irq;
849 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
850
851 /* Set serial data (device specific) */
852 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
853 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
855 PartialDescriptor->Flags = 0;
856 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_SERIAL_DEVICE_DATA);
857
858 SerialDeviceData =
859 (PCM_SERIAL_DEVICE_DATA)&PartialResourceList->PartialDescriptors[3];
860 SerialDeviceData->BaudClock = 1843200; /* UART Clock frequency (Hertz) */
861
862 /* Create controller key */
867 ControllerNumber,
868 0xFFFFFFFF,
870 PartialResourceList,
871 Size,
872 &ControllerKey);
873
874 if (!(PortBitmap & (1 << i)) && !Rs232PortInUse(UlongToPtr(Base)))
875 {
876 /* Detect serial mouse */
878 }
879
880 ControllerNumber++;
881 }
882}
BOOLEAN Rs232PortInUse(PUCHAR Base)
Definition: rs232.c:140
BOOLEAN NTAPI CpDoesPortExist(IN PUCHAR Address)
Definition: cport.c:224
#define UlongToPtr(u)
Definition: config.h:106
static ULONG GetSerialMouseDetectionBitmap(_In_opt_ PCSTR Options)
Definition: machpc.c:742
static VOID DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey, PUCHAR Base)
Definition: machpc.c:558
int Count
Definition: noreturn.cpp:7
@ SerialController
Definition: arc.h:121
struct _CM_SERIAL_DEVICE_DATA * PCM_SERIAL_DEVICE_DATA
struct _CM_SERIAL_DEVICE_DATA CM_SERIAL_DEVICE_DATA

Referenced by DetectIsaBios().

◆ GetSerialMouseDetectionBitmap()

static ULONG GetSerialMouseDetectionBitmap ( _In_opt_ PCSTR  Options)
static

Definition at line 742 of file machpc.c.

744{
745 PCSTR Option, c;
746 ULONG OptionLength, PortBitmap, i;
747
748 if (NtLdrGetOption(Options, "FASTDETECT"))
749 return (1 << MAX_COM_PORTS) - 1;
750
751 Option = NtLdrGetOptionEx(Options, "NOSERIALMICE=", &OptionLength);
752 if (!Option)
753 Option = NtLdrGetOptionEx(Options, "NOSERIALMICE:", &OptionLength);
754
755 if (!Option)
756 return 0;
757
758 /* Invalid port list */
759 if (OptionLength < (sizeof("NOSERIALMICE=COM9") - 1))
760 return (1 << MAX_COM_PORTS) - 1;
761
762 /* Move to the port list */
763 Option += sizeof("NOSERIALMICE=COM") - 1;
764 OptionLength -= sizeof("NOSERIALMICE=COM") - 1;
765
766 PortBitmap = 0;
767 c = Option;
768 for (i = 0; i < OptionLength; i += 2)
769 {
770 UCHAR PortNumber = *c - '0';
771
772 if (PortNumber > 0 && PortNumber <= 9)
773 PortBitmap |= 1 << (PortNumber - 1);
774
775 c += 2;
776 }
777
778 return PortBitmap;
779}
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
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
ULONG PortNumber
Definition: storport.c:18

Referenced by DetectSerialPorts().

◆ GetSerialMousePnpId()

static ULONG GetSerialMousePnpId ( PUCHAR  Port,
char Buffer 
)
static

Definition at line 498 of file machpc.c.

499{
500 ULONG TimeOut;
501 ULONG i = 0;
502 char c;
503 char x;
504
505 WRITE_PORT_UCHAR(Port + 4, 0x09);
506
507 /* Wait 10 milliseconds for the mouse getting ready */
509
510 WRITE_PORT_UCHAR(Port + 4, 0x0b);
511
513
514 for (;;)
515 {
516 TimeOut = 200;
517 while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
518 {
520 --TimeOut;
521 if (TimeOut == 0)
522 {
523 return 0;
524 }
525 }
526
528 if (c == 0x08 || c == 0x28)
529 break;
530 }
531
532 Buffer[i++] = c;
533 x = c + 1;
534
535 for (;;)
536 {
537 TimeOut = 200;
538 while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
539 {
541 --TimeOut;
542 if (TimeOut == 0)
543 return 0;
544 }
546 Buffer[i++] = c;
547 if (c == x)
548 break;
549 if (i >= 256)
550 break;
551 }
552
553 return i;
554}

Referenced by DetectSerialPointerPeripheral().

◆ InitializeSerialPort()

static VOID InitializeSerialPort ( PUCHAR  Port,
UCHAR  LineControl 
)
static

Definition at line 391 of file machpc.c.

393{
394 WRITE_PORT_UCHAR(Port + 3, 0x80); /* set DLAB on */
395 WRITE_PORT_UCHAR(Port, 0x60); /* speed LO byte */
396 WRITE_PORT_UCHAR(Port + 1, 0); /* speed HI byte */
397 WRITE_PORT_UCHAR(Port + 3, LineControl);
398 WRITE_PORT_UCHAR(Port + 1, 0); /* set comm and DLAB to 0 */
399 WRITE_PORT_UCHAR(Port + 4, 0x09); /* DR int enable */
400 READ_PORT_UCHAR(Port + 5); /* clear error bits */
401}

Referenced by DetectSerialPointerPeripheral().

◆ MachInit()

VOID MachInit ( const char CmdLine)

Definition at line 1777 of file machpc.c.

1778{
1779 /* Setup vtbl */
1780 RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
1809
1811}
MACHVTBL MachVtbl
Definition: arcemul.c:21
BOOLEAN PcInitializeBootDevices(VOID)
Definition: hwdisk.c:473
VOID PcGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machpc.c:96
static UCHAR PcGetFloppyCount(VOID)
Definition: machpc.c:1680
PCONFIGURATION_COMPONENT_DATA PcHwDetect(_In_opt_ PCSTR Options)
Definition: machpc.c:1692
VOID PcHwIdle(VOID)
Definition: machpc.c:1722
VOID PcPrepareForReactOS(VOID)
Definition: machpc.c:1814
VOID PcBeep(VOID)
Definition: pcbeep.c:34
VOID PcConsPutChar(int Ch)
Definition: pccons.c:28
BOOLEAN PcConsKbHit(VOID)
Definition: pccons.c:69
int PcConsGetCh(void)
Definition: pccons.c:90
BOOLEAN PcDiskReadLogicalSectors(IN UCHAR DriveNumber, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
Definition: pcdisk.c:758
ULONG PcDiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: pcdisk.c:827
BOOLEAN PcDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: pcdisk.c:798
VOID HalpCalibrateStallExecution(VOID)
Definition: pchw.c:105
PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap(ULONG *MemoryMapSize)
Definition: pcmem.c:599
TIMEINFO * PcGetTime(VOID)
Definition: pcrtc.c:24
VOID PcVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
Definition: pcvideo.c:1010
BOOLEAN PcVideoIsPaletteFixed(VOID)
Definition: pcvideo.c:1114
VOID PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: pcvideo.c:1120
VOID PcVideoSync(VOID)
Definition: pcvideo.c:1138
VOID PcVideoGetFontsFromFirmware(PULONG RomFontPointers)
Definition: pcvideo.c:976
VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: pcvideo.c:946
VOID PcVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: pcvideo.c:1129
VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayModeName, BOOLEAN Init)
Definition: pcvideo.c:888
ULONG PcVideoGetBufferSize(VOID)
Definition: pcvideo.c:970
VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: pcvideo.c:1105
VOID PcVideoClearScreen(UCHAR Attr)
Definition: pcvideo.c:1089
VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: pcvideo.c:1048
VOID PcVideoHideShowTextCursor(BOOLEAN Show)
Definition: pcvideo.c:1035
VOID(* VideoGetPaletteColor)(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: machine.h:56
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
VIDEODISPLAYMODE(* VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init)
Definition: machine.h:46
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

◆ PcGetExtendedBIOSData()

VOID PcGetExtendedBIOSData ( PULONG  ExtendedBIOSDataArea,
PULONG  ExtendedBIOSDataSize 
)

Definition at line 96 of file machpc.c.

97{
98 REGS BiosRegs;
99
100 /* Get address and size of the extended BIOS data area */
101 BiosRegs.d.eax = 0xC100;
102 Int386(0x15, &BiosRegs, &BiosRegs);
103 if (INT386_SUCCESS(BiosRegs))
104 {
105 *ExtendedBIOSDataArea = BiosRegs.w.es << 4;
106 *ExtendedBIOSDataSize = 1024;
107 }
108 else
109 {
110 WARN("Int 15h AH=C1h call failed\n");
113 }
114}
#define ExtendedBIOSDataArea
Definition: winldr.c:346
#define ExtendedBIOSDataSize
Definition: winldr.c:347
#define INT386_SUCCESS(regs)
Definition: pcbios.h:179
unsigned long eax
Definition: pcbios.h:91
DWORDREGS d
Definition: pcbios.h:161

Referenced by MachInit().

◆ PcGetFloppyCount()

static UCHAR PcGetFloppyCount ( VOID  )
static

Definition at line 1680 of file machpc.c.

1681{
1682 UCHAR Data;
1683
1684 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
1685 Data = READ_PORT_UCHAR((PUCHAR)0x71);
1686
1687 return ((Data & 0xF0) ? 1 : 0) + ((Data & 0x0F) ? 1 : 0);
1688}

Referenced by MachInit().

◆ PcGetHarddiskConfigurationData()

static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData ( UCHAR  DriveNumber,
ULONG pSize 
)
static

Definition at line 120 of file machpc.c.

121{
122 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
124 // EXTENDED_GEOMETRY ExtGeometry;
125 GEOMETRY Geometry;
126 ULONG Size;
127
128 //
129 // Initialize returned size
130 //
131 *pSize = 0;
132
133 /* Set 'Configuration Data' value */
136 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
137 if (PartialResourceList == NULL)
138 {
139 ERR("Failed to allocate resource descriptor\n");
140 return NULL;
141 }
142
143 RtlZeroMemory(PartialResourceList, Size);
144 PartialResourceList->Version = 1;
145 PartialResourceList->Revision = 1;
146 PartialResourceList->Count = 1;
147 PartialResourceList->PartialDescriptors[0].Type =
149// PartialResourceList->PartialDescriptors[0].ShareDisposition =
150// PartialResourceList->PartialDescriptors[0].Flags =
151 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
153
154 /* Get pointer to geometry data */
155 DiskGeometry = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
156
157 /* Get the disk geometry */
158#if 0 // This is somehow replaced by what PcDiskGetDriveGeometry() does internally.
159 ExtGeometry.Size = sizeof(EXTENDED_GEOMETRY);
160 if (DiskGetExtendedDriveParameters(DriveNumber, &ExtGeometry, ExtGeometry.Size))
161 {
162 DiskGeometry->BytesPerSector = ExtGeometry.BytesPerSector;
163 DiskGeometry->NumberOfCylinders = ExtGeometry.Cylinders;
164 DiskGeometry->SectorsPerTrack = ExtGeometry.SectorsPerTrack;
165 DiskGeometry->NumberOfHeads = ExtGeometry.Heads;
166 }
167 else
168#endif
169 if (PcDiskGetDriveGeometry(DriveNumber, &Geometry))
170 {
171 DiskGeometry->BytesPerSector = Geometry.BytesPerSector;
172 DiskGeometry->NumberOfCylinders = Geometry.Cylinders;
173 DiskGeometry->SectorsPerTrack = Geometry.Sectors;
174 DiskGeometry->NumberOfHeads = Geometry.Heads;
175 }
176 else
177 {
178 TRACE("Reading disk geometry failed\n");
179 FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
180 return NULL;
181 }
182 TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
183 DriveNumber,
184 DiskGeometry->NumberOfCylinders,
185 DiskGeometry->NumberOfHeads,
186 DiskGeometry->SectorsPerTrack,
187 DiskGeometry->BytesPerSector);
188
189 //
190 // Return configuration data
191 //
192 *pSize = Size;
193 return PartialResourceList;
194}
struct _EXTENDED_GEOMETRY EXTENDED_GEOMETRY
FORCEINLINE VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: mm.h:181
static BOOLEAN DiskGetExtendedDriveParameters(IN UCHAR DriveNumber, IN PPC_DISK_DRIVE DiskDrive, OUT PVOID Buffer, IN USHORT BufferSize)
Definition: pcdisk.c:294
Definition: disk.h:25
ULONG BytesPerSector
Definition: disk.h:29
ULONG Sectors
Definition: disk.h:28
ULONG Cylinders
Definition: disk.h:26
ULONG Heads
Definition: disk.h:27
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct _CM_DISK_GEOMETRY_DEVICE_DATA CM_DISK_GEOMETRY_DEVICE_DATA

Referenced by PcHwDetect().

◆ PcGetSerialPort()

static ULONG PcGetSerialPort ( ULONG  Index,
PULONG  Irq 
)
static

Definition at line 717 of file machpc.c.

718{
719 static const ULONG PcIrq[MAX_COM_PORTS] = {4, 3, 4, 3};
720 PUSHORT BasePtr;
721
722 /*
723 * The BIOS data area 0x400 holds the address of the first valid COM port.
724 * Each COM port address is stored in a 2-byte field.
725 * Infos at: http://www.bioscentral.com/misc/bda.htm
726 */
727 BasePtr = (PUSHORT)0x400;
728 *Irq = PcIrq[Index];
729
730 return (ULONG) *(BasePtr + Index);
731}
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by DetectIsaBios().

◆ PcHwDetect()

PCONFIGURATION_COMPONENT_DATA PcHwDetect ( _In_opt_ PCSTR  Options)

Definition at line 1692 of file machpc.c.

1694{
1696 ULONG BusNumber = 0;
1697
1698 TRACE("DetectHardware()\n");
1699
1700 /* Create the 'System' key */
1701 // TODO: Discover and set the other machine types
1702 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
1703
1706
1707 /* Detect buses */
1708 DetectPciBios(SystemKey, &BusNumber);
1709 DetectApmBios(SystemKey, &BusNumber);
1710 DetectPnpBios(SystemKey, &BusNumber);
1711 DetectIsaBios(Options, SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
1712 DetectAcpiBios(SystemKey, &BusNumber);
1713
1714 // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
1715 // CM_ROM_BLOCK data into the 'System' key's configuration data.
1716
1717 TRACE("DetectHardware() Done\n");
1718 return SystemKey;
1719}
VOID FldrCreateSystemKey(_Out_ PCONFIGURATION_COMPONENT_DATA *SystemNode, _In_ PCSTR IdentifierString)
Definition: archwsup.c:135
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwacpi.c:54
VOID DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwpci.c:176
BOOLEAN PcFindPciBios(PPCI_REGISTRY_INFO BusData)
Definition: hwpci.c:80
FIND_PCI_BIOS FindPciBios
Definition: hwpci.c:26
VOID DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwapm.c:46
static VOID DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: machpc.c:255
static VOID DetectIsaBios(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA SystemKey, _Out_ ULONG *BusNumber)
Definition: machpc.c:1622
static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: machpc.c:120
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData
Definition: pchw.c:45
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160

Referenced by MachInit().

◆ PcHwIdle()

VOID PcHwIdle ( VOID  )

Definition at line 1722 of file machpc.c.

1723{
1724 REGS Regs;
1725
1726 /* Select APM 1.0+ function */
1727 Regs.b.ah = 0x53;
1728
1729 /* Function 05h: CPU idle */
1730 Regs.b.al = 0x05;
1731
1732 /* Call INT 15h */
1733 Int386(0x15, &Regs, &Regs);
1734
1735 /* Check if successfull (CF set on error) */
1736 if (INT386_SUCCESS(Regs))
1737 return;
1738
1739 /*
1740 * No futher processing here.
1741 * Optionally implement HLT instruction handling.
1742 */
1743}

Referenced by MachInit().

◆ PcPrepareForReactOS()

VOID PcPrepareForReactOS ( VOID  )

Definition at line 1814 of file machpc.c.

1815{
1816 /* On PC, prepare video and turn off the floppy motor */
1819}
VOID __cdecl DiskStopFloppyMotor(VOID)
Definition: pc98hw.c:1235
VOID PcVideoPrepareForReactOS(VOID)
Definition: pcvideo.c:1161

Referenced by MachInit().

◆ PS2ControllerWait()

static VOID PS2ControllerWait ( VOID  )
static

Definition at line 1178 of file machpc.c.

1179{
1180 ULONG Timeout;
1181 UCHAR Status;
1182
1184 {
1187 return;
1188
1189 /* Sleep for one millisecond */
1191 }
1192}
#define CONTROLLER_STATUS_INPUT_BUFFER_FULL
Definition: machpc.c:81
#define CONTROLLER_TIMEOUT
Definition: machpc.c:92
static ULONG Timeout
Definition: ping.c:61

Referenced by DetectPS2AuxDevice(), and DetectPS2AuxPort().