ReactOS 0.4.16-dev-2104-gb84fa49
machpc.c File Reference
#include <freeldr.h>
#include <cportlib/cportlib.h>
#include "../ntldr/ntldropts.h"
#include <debug.h>
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for machpc.c:

Go to the source code of this file.

Classes

struct  _PNP_DOCK_INFO
 

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
 

Typedefs

typedef struct _PNP_DOCK_INFO PNP_DOCK_INFO
 
typedef struct _PNP_DOCK_INFOPPNP_DOCK_INFO
 

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.

Typedef Documentation

◆ PNP_DOCK_INFO

◆ PPNP_DOCK_INFO

Function Documentation

◆ BiosIsVesaDdcSupported()

BOOLEAN BiosIsVesaDdcSupported ( VOID  )

Definition at line 241 of file pcvesa.c.

242{
243 REGS Regs;
244
245 TRACE("BiosIsVesaDdcSupported()\n");
246
247 Regs.w.ax = 0x4F15;
248 Regs.b.bl = 0;
249 Regs.w.cx = 0;
250 Regs.w.es = 0;
251 Regs.w.di = 0;
252 Int386(0x10, &Regs, &Regs);
253
254 TRACE("AL = 0x%x\n", Regs.b.al);
255 TRACE("AH = 0x%x\n", Regs.b.ah);
256
257 TRACE("BL = 0x%x\n", Regs.b.bl);
258
259 if (Regs.w.ax != 0x004F)
260 {
261 WARN("VBE/DDC Installation check function not supported (AL=0x%x) or failed (AH=0x%x)\n",
262 Regs.b.al, Regs.b.ah);
263 return FALSE;
264 }
265
266 return (Regs.b.ah == 0);
267}
#define WARN(fmt,...)
Definition: precomp.h:61
#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:136
unsigned char al
Definition: pcbios.h:133
unsigned char ah
Definition: pcbios.h:134
unsigned short es
Definition: pcbios.h:123
unsigned short di
Definition: pcbios.h:119
unsigned short cx
Definition: pcbios.h:115
unsigned short ax
Definition: pcbios.h:113
Definition: pcbios.h:161
BYTEREGS b
Definition: pcbios.h:165
WORDREGS w
Definition: pcbios.h:164

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: precomp.h:57
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:24
#define BIOSCALLBUFOFFSET
Definition: x86common.h:25
#define BIOSCALLBUFFER
Definition: x86common.h:12

Referenced by DetectDisplayController().

◆ BiosVesaReadEdid()

BOOLEAN BiosVesaReadEdid ( VOID  )

Definition at line 270 of file pcvesa.c.

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

Referenced by DetectDisplayController().

◆ ChainLoadBiosBootSectorCode()

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

Definition at line 1752 of file machpc.c.

1755{
1756 REGS Regs;
1757
1758 RtlZeroMemory(&Regs, sizeof(Regs));
1759
1760 /* Set the boot drive and the boot partition */
1761 Regs.b.dl = (UCHAR)(BootDrive ? BootDrive : FrldrBootDrive);
1762 Regs.b.dh = (UCHAR)(BootPartition ? BootPartition : FrldrBootPartition);
1763
1764 /*
1765 * Don't stop the floppy drive motor when we are just booting a bootsector,
1766 * a drive, or a partition. If we were to stop the floppy motor, the BIOS
1767 * wouldn't be informed and if the next read is to a floppy then the BIOS
1768 * will still think the motor is on and this will result in a read error.
1769 */
1770 // DiskStopFloppyMotor();
1771
1772 Relocator16Boot(&Regs,
1773 /* Stack segment:pointer */
1774 0x0000, 0x7C00,
1775 /* Code segment:pointer */
1776 0x0000, 0x7C00);
1777}
DECLSPEC_NORETURN VOID __cdecl Relocator16Boot(IN REGS *In, IN USHORT StackSegment, IN USHORT StackPointer, IN USHORT CodeSegment, IN USHORT CodePointer)
unsigned char dl
Definition: pcbios.h:142
unsigned char dh
Definition: pcbios.h:143
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 1580 of file machpc.c.

1581{
1583 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1584 USHORT VesaVersion;
1585
1586 /* FIXME: Set 'ComponentInformation' value */
1587
1588 VesaVersion = BiosIsVesaSupported();
1589 if (VesaVersion != 0)
1590 {
1591 TRACE("VESA version %c.%c\n",
1592 (VesaVersion >> 8) + '0',
1593 (VesaVersion & 0xFF) + '0');
1594 }
1595 else
1596 {
1597 TRACE("VESA not supported\n");
1598 }
1599
1600 if (VesaVersion >= 0x0200)
1601 Identifier = "VBE Display";
1602 else
1603 Identifier = "VGA Display";
1604
1609 0,
1610 0xFFFFFFFF,
1611 Identifier,
1612 NULL,
1613 0,
1614 &ControllerKey);
1615
1616 /* FIXME: Add display peripheral (monitor) data */
1617 if (VesaVersion != 0)
1618 {
1620 {
1621 TRACE("VESA/DDC supported!\n");
1622 if (BiosVesaReadEdid())
1623 {
1624 TRACE("EDID data read successfully!\n");
1625 }
1626 }
1627 }
1628}
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:270
BOOLEAN BiosIsVesaDdcSupported(VOID)
Definition: pcvesa.c:241
USHORT BiosIsVesaSupported(VOID)
Definition: pcvesa.c:160
unsigned short USHORT
Definition: pedump.c:61
@ ControllerClass
Definition: arc.h:103
@ DisplayController
Definition: arc.h:132
@ ConsoleOut
Definition: arc.h:92
@ Output
Definition: arc.h:94
const char * PCSTR
Definition: typedefs.h:52

Referenced by DetectIsaBios().

◆ DetectDockingStation()

static VOID DetectDockingStation ( _Inout_ PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 193 of file machpc.c.

195{
196 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
197 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
198 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
199 PDOCKING_STATE_INFORMATION DockingState;
200 PPNP_DOCK_INFO DockInfo;
202
204
205 /* Build full device descriptor */
208 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
209 if (PartialResourceList == NULL)
210 {
211 ERR("Failed to allocate resource descriptor\n");
212 return;
213 }
214
215 /* Initialize resource descriptor */
216 RtlZeroMemory(PartialResourceList, Size);
217 PartialResourceList->Version = 0;
218 PartialResourceList->Revision = 0;
219 PartialResourceList->Count = 1;
220
221 /* Set device specific data */
222 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
223 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
225 PartialDescriptor->Flags = 0;
226 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(DOCKING_STATE_INFORMATION);
227
228 DockingState = (PDOCKING_STATE_INFORMATION)&PartialResourceList->PartialDescriptors[1];
229 DockingState->ReturnCode = Result;
230 if (Result == 0)
231 {
232 DockInfo = (PPNP_DOCK_INFO)DiskReadBuffer;
233 DockingState->DockLocationID = DockInfo->DockLocationID;
234 DockingState->SerialNumber = DockInfo->SerialNumber;
235 DockingState->Capabilities = DockInfo->Capabilities;
236 TRACE("System docked\n");
237 TRACE("Location: 0x%08lx\n", DockInfo->DockLocationID);
238 TRACE("Serial: 0x%08lx\n", DockInfo->SerialNumber);
239 TRACE("Capabilities: 0x%04hx\n", DockInfo->Capabilities);
240 }
241
242 /* Create controller key */
246 0,
247 0,
248 0xFFFFFFFF,
249 "Docking State Information",
250 PartialResourceList,
251 Size,
252 &PeripheralKey);
253}
#define DiskReadBuffer
Definition: hardware.h:33
ULONG __cdecl PnpBiosGetDockStationInformation(UCHAR *DockingStationInfo)
PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: heap.c:533
if(dx< 0)
Definition: linetemp.h:194
struct _PNP_DOCK_INFO * PPNP_DOCK_INFO
struct _DOCKING_STATE_INFORMATION DOCKING_STATE_INFORMATION
struct _DOCKING_STATE_INFORMATION * PDOCKING_STATE_INFORMATION
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
#define CmResourceTypeDeviceSpecific
Definition: restypes.h:108
@ PeripheralClass
Definition: arc.h:104
@ DockingInformation
Definition: arc.h:151
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@432 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@432::@441 DeviceSpecificData
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: restypes.h:100
ULONG SerialNumber
Definition: machpc.c:98
ULONG DockLocationID
Definition: machpc.c:97
USHORT Capabilities
Definition: machpc.c:99
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:4539
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
@ 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 1632 of file machpc.c.

1636{
1637 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1639 ULONG Size;
1640
1641 /* Set 'Configuration Data' value */
1642 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1644 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1645 if (PartialResourceList == NULL)
1646 {
1647 ERR("Failed to allocate resource descriptor\n");
1648 return;
1649 }
1650
1651 /* Initialize resource descriptor */
1652 RtlZeroMemory(PartialResourceList, Size);
1653 PartialResourceList->Version = 1;
1654 PartialResourceList->Revision = 1;
1655 PartialResourceList->Count = 0;
1656
1657 /* Create new bus key */
1658 FldrCreateComponentKey(SystemKey,
1661 0,
1662 0,
1663 0xFFFFFFFF,
1664 "ISA",
1665 PartialResourceList,
1666 Size,
1667 &BusKey);
1668
1669 /* Increment bus number */
1670 (*BusNumber)++;
1671
1672 /* Detect ISA/BIOS devices */
1673 DetectBiosDisks(SystemKey, BusKey);
1675 DetectParallelPorts(BusKey);
1677 DetectPS2Mouse(BusKey);
1678#if defined(_M_IX86)
1679 DetectBusMouse(BusKey);
1680#endif
1682
1683 /* FIXME: Detect more ISA devices */
1684}
static ULONG PcGetSerialPort(ULONG Index, PULONG Irq)
Definition: machpc.c:723
#define MAX_COM_PORTS
Definition: machpc.c:29
static VOID DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1121
static VOID DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1298
static VOID DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:895
VOID DetectSerialPorts(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA BusKey, _In_ GET_SERIAL_PORT MachGetSerialPort, _In_ ULONG Count)
Definition: machpc.c:789
static VOID DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1580
VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pchw.c:344
@ AdapterClass
Definition: arc.h:102
@ MultiFunctionAdapter
Definition: arc.h:125
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3540

Referenced by PcHwDetect().

◆ DetectKeyboardController()

static VOID DetectKeyboardController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1121 of file machpc.c.

1122{
1123 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1124 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
1125 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1126 ULONG Size;
1127
1128 /* Set 'Configuration Data' value */
1129 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
1131 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1132 if (PartialResourceList == NULL)
1133 {
1134 ERR("Failed to allocate resource descriptor\n");
1135 return;
1136 }
1137
1138 /* Initialize resource descriptor */
1139 RtlZeroMemory(PartialResourceList, Size);
1140 PartialResourceList->Version = 1;
1141 PartialResourceList->Revision = 1;
1142 PartialResourceList->Count = 3;
1143
1144 /* Set Interrupt */
1145 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1146 PartialDescriptor->Type = CmResourceTypeInterrupt;
1147 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1148 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1149 PartialDescriptor->u.Interrupt.Level = 1;
1150 PartialDescriptor->u.Interrupt.Vector = 1;
1151 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
1152
1153 /* Set IO Port 0x60 */
1154 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
1155 PartialDescriptor->Type = CmResourceTypePort;
1157 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1158 PartialDescriptor->u.Port.Start.LowPart = 0x60;
1159 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1160 PartialDescriptor->u.Port.Length = 1;
1161
1162 /* Set IO Port 0x64 */
1163 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
1164 PartialDescriptor->Type = CmResourceTypePort;
1166 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1167 PartialDescriptor->u.Port.Start.LowPart = 0x64;
1168 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1169 PartialDescriptor->u.Port.Length = 1;
1170
1171 /* Create controller key */
1175 Input | ConsoleIn,
1176 0,
1177 0xFFFFFFFF,
1178 NULL,
1179 PartialResourceList,
1180 Size,
1181 &ControllerKey);
1182
1183 DetectKeyboardPeripheral(ControllerKey);
1184}
static VOID DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: machpc.c:1056
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CmResourceTypePort
Definition: restypes.h:104
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: restypes.h:117
#define CmResourceTypeInterrupt
Definition: restypes.h:105
@ KeyboardController
Definition: arc.h:135
@ ConsoleIn
Definition: arc.h:91
@ Input
Definition: arc.h:93
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@432::@434 Port
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@432::@435 Interrupt
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241

Referenced by DetectIsaBios().

◆ DetectKeyboardDevice()

BOOLEAN DetectKeyboardDevice ( VOID  )

Definition at line 987 of file machpc.c.

988{
990 UCHAR Scancode;
991 ULONG Loops;
993
994 /* Identify device */
996
997 /* Wait for reply */
998 for (Loops = 0; Loops < 100; Loops++)
999 {
1003 break;
1004 }
1005
1007 {
1008 /* PC/XT keyboard or no keyboard */
1009 Result = FALSE;
1010 }
1011
1013 if (Scancode != 0xFA)
1014 {
1015 /* No ACK received */
1016 Result = FALSE;
1017 }
1018
1020
1023 {
1024 /* Found AT keyboard */
1025 return Result;
1026 }
1027
1029 if (Scancode != 0xAB)
1030 {
1031 /* No 0xAB received */
1032 Result = FALSE;
1033 }
1034
1036
1039 {
1040 /* No byte in buffer */
1041 Result = FALSE;
1042 }
1043
1045 if (Scancode != 0x41)
1046 {
1047 /* No 0x41 received */
1048 Result = FALSE;
1049 }
1050
1051 /* Found MF-II keyboard */
1052 return Result;
1053}
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 1056 of file machpc.c.

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

896{
897 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
898 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
899 ULONG Irq[MAX_LPT_PORTS] = {7, 5, (ULONG) - 1};
900 CHAR Identifier[80];
901 PCONFIGURATION_COMPONENT_DATA ControllerKey;
902 PUSHORT BasePtr;
903 ULONG Base;
904 ULONG ControllerNumber = 0;
905 ULONG i;
906 ULONG Size;
907
908 TRACE("DetectParallelPorts() called\n");
909
910 /*
911 * The BIOS data area 0x408 holds the address of the first valid LPT port.
912 * Each LPT port address is stored in a 2-byte field.
913 * Infos at: https://web.archive.org/web/20240119203029/http://www.bioscentral.com/misc/bda.htm
914 */
915 BasePtr = (PUSHORT)0x408;
916
917 for (i = 0; i < MAX_LPT_PORTS; i++, BasePtr++)
918 {
919 Base = (ULONG) * BasePtr;
920 if (Base == 0)
921 continue;
922
923 TRACE("Parallel port %u: %x\n", ControllerNumber, Base);
924
925 /* Set 'Identifier' value */
926 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "PARALLEL%ld", i + 1);
927
928 /* Build full device descriptor */
930 if (Irq[i] != (ULONG) - 1)
932
933 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
934 if (PartialResourceList == NULL)
935 {
936 ERR("Failed to allocate resource descriptor! Ignoring remaining parallel ports. (i = %lu)\n", i);
937 break;
938 }
939
940 /* Initialize resource descriptor */
941 RtlZeroMemory(PartialResourceList, Size);
942 PartialResourceList->Version = 1;
943 PartialResourceList->Revision = 1;
944 PartialResourceList->Count = (Irq[i] != (ULONG) - 1) ? 2 : 1;
945
946 /* Set IO Port */
947 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
948 PartialDescriptor->Type = CmResourceTypePort;
950 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
951 PartialDescriptor->u.Port.Start.LowPart = Base;
952 PartialDescriptor->u.Port.Start.HighPart = 0x0;
953 PartialDescriptor->u.Port.Length = 3;
954
955 /* Set Interrupt */
956 if (Irq[i] != (ULONG) - 1)
957 {
958 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
959 PartialDescriptor->Type = CmResourceTypeInterrupt;
961 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
962 PartialDescriptor->u.Interrupt.Level = Irq[i];
963 PartialDescriptor->u.Interrupt.Vector = Irq[i];
964 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
965 }
966
967 /* Create controller key */
971 Output,
972 ControllerNumber,
973 0xFFFFFFFF,
975 PartialResourceList,
976 Size,
977 &ControllerKey);
978
979 ControllerNumber++;
980 }
981
982 TRACE("DetectParallelPorts() done\n");
983}
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:2486
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:133
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 257 of file machpc.c.

258{
259 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
263 ULONG x;
264 ULONG NodeSize = 0;
265 ULONG NodeCount = 0;
267 ULONG FoundNodeCount;
268 int i;
269 ULONG PnpBufferSize;
270 ULONG PnpBufferSizeLimit;
271 ULONG Size;
272 char *Ptr;
273
275 if (InstData == NULL || strncmp((CHAR*)InstData->Signature, "$PnP", 4))
276 {
277 TRACE("PnP-BIOS not supported\n");
278 return;
279 }
280
281 TRACE("PnP-BIOS supported\n");
282 TRACE("Signature '%c%c%c%c'\n",
283 InstData->Signature[0], InstData->Signature[1],
284 InstData->Signature[2], InstData->Signature[3]);
285
286 x = PnpBiosGetDeviceNodeCount(&NodeSize, &NodeCount);
287 if (x == 0x82)
288 {
289 TRACE("PnP-BIOS function 'Get Number of System Device Nodes' not supported\n");
290 return;
291 }
292
293 NodeCount &= 0xFF; // needed since some fscked up BIOSes return
294 // wrong info (e.g. Mac Virtual PC)
295 // e.g. look: https://web.archive.org/web/20080329010332/http://my.execpc.com/~geezer/osd/pnp/pnp16.c
296 if (x != 0 || NodeSize == 0 || NodeCount == 0)
297 {
298 ERR("PnP-BIOS failed to enumerate device nodes\n");
299 return;
300 }
301 TRACE("MaxNodeSize %u NodeCount %u\n", NodeSize, NodeCount);
302 TRACE("Estimated buffer size %u\n", NodeSize * NodeCount);
303
304 /* Set 'Configuration Data' value */
305 PnpBufferSizeLimit = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK)
306 + (NodeSize * NodeCount);
307 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) + PnpBufferSizeLimit;
308 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
309 if (PartialResourceList == NULL)
310 {
311 ERR("Failed to allocate resource descriptor\n");
312 return;
313 }
314
315 /* Initialize resource descriptor */
316 RtlZeroMemory(PartialResourceList, Size);
317 PartialResourceList->Version = 1;
318 PartialResourceList->Revision = 1;
319 PartialResourceList->Count = 1;
320 PartialResourceList->PartialDescriptors[0].Type =
322 PartialResourceList->PartialDescriptors[0].ShareDisposition =
324
325 /* The buffer starts after PartialResourceList->PartialDescriptors[0] */
326 Ptr = (char *)(PartialResourceList + 1);
327
328 /* Set installation check data */
329 memcpy (Ptr, InstData, sizeof(CM_PNP_BIOS_INSTALLATION_CHECK));
331 PnpBufferSize = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK);
332
333 /* Copy device nodes */
334 FoundNodeCount = 0;
335 for (i = 0; i < 0xFF; i++)
336 {
337 NodeNumber = (UCHAR)i;
338
340 if (x == 0)
341 {
343
344 TRACE("Node: %u Size %u (0x%x)\n",
345 DeviceNode->Node,
346 DeviceNode->Size,
347 DeviceNode->Size);
348
349 if (PnpBufferSize + DeviceNode->Size > PnpBufferSizeLimit)
350 {
351 ERR("Buffer too small! Ignoring remaining device nodes. (i = %d)\n", i);
352 break;
353 }
354
356
357 Ptr += DeviceNode->Size;
358 PnpBufferSize += DeviceNode->Size;
359
360 FoundNodeCount++;
361 if (FoundNodeCount >= NodeCount)
362 break;
363 }
364 }
365
366 /* Set real data size */
367 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
368 PnpBufferSize;
369 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) + PnpBufferSize;
370
371 TRACE("Real buffer size: %u\n", PnpBufferSize);
372 TRACE("Resource size: %u\n", Size);
373
374 /* Create component key */
375 FldrCreateComponentKey(SystemKey,
378 0,
379 0,
380 0xFFFFFFFF,
381 "PNP BIOS",
382 PartialResourceList,
383 Size,
384 &BusKey);
385
386 DetectDockingStation(BusKey);
387
388 (*BusNumber)++;
389}
@ DeviceNode
Definition: Node.h:9
ULONG __cdecl PnpBiosGetDeviceNode(UCHAR *NodeId, UCHAR *NodeBuffer)
ULONG __cdecl PnpBiosGetDeviceNodeCount(ULONG *NodeSize, ULONG *NodeCount)
ULONG_PTR __cdecl PnpBiosSupported(VOID)
_ACRTIMP int __cdecl strncmp(const char *, const char *, size_t)
Definition: string.c:3330
_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:193
#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 1249 of file machpc.c.

1250{
1251 UCHAR Scancode;
1252 UCHAR Status;
1253 ULONG Loops;
1255
1260
1261 /* Identify device */
1263
1264 /* Wait for reply */
1265 for (Loops = 0; Loops < 100; Loops++)
1266 {
1270 break;
1271 }
1272
1275 Result = FALSE;
1276
1278 if (Scancode != 0xFA)
1279 Result = FALSE;
1280
1282
1285 Result = FALSE;
1286
1288 if (Scancode != 0x00)
1289 Result = FALSE;
1290
1291 return Result;
1292}
#define CONTROLLER_COMMAND_WRITE_MOUSE
Definition: machpc.c:77
static VOID PS2ControllerWait(VOID)
Definition: machpc.c:1188
#define CONTROLLER_REGISTER_CONTROL
Definition: machpc.c:62

Referenced by DetectPS2Mouse().

◆ DetectPS2AuxPort()

static BOOLEAN DetectPS2AuxPort ( VOID  )
static

Definition at line 1206 of file machpc.c.

1207{
1208#if 1
1209 /* Current detection is too unreliable. Just do as if
1210 * the PS/2 aux port is always present
1211 */
1212 return TRUE;
1213#else
1214 ULONG Loops;
1215 UCHAR Status;
1216
1217 /* Put the value 0x5A in the output buffer using the
1218 * "WriteAuxiliary Device Output Buffer" command (0xD3).
1219 * Poll the Status Register for a while to see if the value really turns up
1220 * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1221 * to 1 in the Status Register, we assume this controller has an
1222 * Auxiliary Port (a.k.a. Mouse Port).
1223 */
1228
1229 /* 0x5A is a random dummy value */
1231 0x5A);
1232
1233 for (Loops = 0; Loops < 10; Loops++)
1234 {
1238 break;
1239 }
1240
1242
1244#endif
1245}
#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 1298 of file machpc.c.

1299{
1300 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1301 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1302 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
1303 ULONG Size;
1304
1305 if (DetectPS2AuxPort())
1306 {
1307 TRACE("Detected PS2 port\n");
1308
1309 PartialResourceList = FrLdrHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST), TAG_HW_RESOURCE_LIST);
1310 if (PartialResourceList == NULL)
1311 {
1312 ERR("Failed to allocate resource descriptor\n");
1313 return;
1314 }
1315
1316 /* Initialize resource descriptor */
1317 RtlZeroMemory(PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST));
1318 PartialResourceList->Version = 1;
1319 PartialResourceList->Revision = 1;
1320 PartialResourceList->Count = 1;
1321
1322 /* Set Interrupt */
1323 PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeInterrupt;
1325 PartialResourceList->PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1326 PartialResourceList->PartialDescriptors[0].u.Interrupt.Level = 12;
1327 PartialResourceList->PartialDescriptors[0].u.Interrupt.Vector = 12;
1328 PartialResourceList->PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF;
1329
1330 /* Create controller key */
1334 Input,
1335 0,
1336 0xFFFFFFFF,
1337 NULL,
1338 PartialResourceList,
1340 &ControllerKey);
1341
1342 if (DetectPS2AuxDevice())
1343 {
1344 TRACE("Detected PS2 mouse\n");
1345
1346 /* Initialize resource descriptor */
1347 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1349 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1350 if (PartialResourceList == NULL)
1351 {
1352 ERR("Failed to allocate resource descriptor\n");
1353 return;
1354 }
1355
1356 RtlZeroMemory(PartialResourceList, Size);
1357 PartialResourceList->Version = 1;
1358 PartialResourceList->Revision = 1;
1359 PartialResourceList->Count = 0;
1360
1361 /* Create peripheral key */
1362 FldrCreateComponentKey(ControllerKey,
1365 Input,
1366 0,
1367 0xFFFFFFFF,
1368 "MICROSOFT PS2 MOUSE",
1369 PartialResourceList,
1370 Size,
1371 &PeripheralKey);
1372 }
1373 }
1374}
static BOOLEAN DetectPS2AuxDevice(VOID)
Definition: machpc.c:1249
static BOOLEAN DetectPS2AuxPort(VOID)
Definition: machpc.c:1206
@ PointerController
Definition: arc.h:134
@ PointerPeripheral
Definition: arc.h:144

Referenced by DetectIsaBios().

◆ DetectSerialMouse()

static ULONG DetectSerialMouse ( PUCHAR  Port)
static

Definition at line 409 of file machpc.c.

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

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

794{
795 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
796 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
797 PCM_SERIAL_DEVICE_DATA SerialDeviceData;
798 ULONG Irq;
799 ULONG Base;
800 CHAR Identifier[80];
801 ULONG ControllerNumber = 0;
802 PCONFIGURATION_COMPONENT_DATA ControllerKey;
803 ULONG i;
804 ULONG Size;
805 ULONG PortBitmap;
806
807 TRACE("DetectSerialPorts()\n");
808
810
811 for (i = 0; i < Count; i++)
812 {
813 Base = MachGetSerialPort(i, &Irq);
814 if ((Base == 0) || !CpDoesPortExist(UlongToPtr(Base)))
815 continue;
816
817 TRACE("Found COM%u port at 0x%x\n", i + 1, Base);
818
819 /* Set 'Identifier' value */
820 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "COM%ld", i + 1);
821
822 /* Build full device descriptor */
825 sizeof(CM_SERIAL_DEVICE_DATA);
826 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
827 if (PartialResourceList == NULL)
828 {
829 ERR("Failed to allocate resource descriptor! Ignoring remaining serial ports. (i = %lu, Count = %lu)\n",
830 i, Count);
831 break;
832 }
833
834 /* Initialize resource descriptor */
835 RtlZeroMemory(PartialResourceList, Size);
836 PartialResourceList->Version = 1;
837 PartialResourceList->Revision = 1;
838 PartialResourceList->Count = 3;
839
840 /* Set IO Port */
841 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
842 PartialDescriptor->Type = CmResourceTypePort;
844 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
845 PartialDescriptor->u.Port.Start.LowPart = Base;
846 PartialDescriptor->u.Port.Start.HighPart = 0x0;
847 PartialDescriptor->u.Port.Length = 8;
848
849 /* Set Interrupt */
850 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
851 PartialDescriptor->Type = CmResourceTypeInterrupt;
853 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
854 PartialDescriptor->u.Interrupt.Level = Irq;
855 PartialDescriptor->u.Interrupt.Vector = Irq;
856 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
857
858 /* Set serial data (device specific) */
859 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
860 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
862 PartialDescriptor->Flags = 0;
863 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_SERIAL_DEVICE_DATA);
864
865 SerialDeviceData =
866 (PCM_SERIAL_DEVICE_DATA)&PartialResourceList->PartialDescriptors[3];
867 SerialDeviceData->BaudClock = 1843200; /* UART Clock frequency (Hertz) */
868
869 /* Create controller key */
874 ControllerNumber,
875 0xFFFFFFFF,
877 PartialResourceList,
878 Size,
879 &ControllerKey);
880
881 if (!(PortBitmap & (1 << i)) && !Rs232PortInUse(UlongToPtr(Base)))
882 {
883 /* Detect serial mouse */
885 }
886
887 ControllerNumber++;
888 }
889}
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:749
static VOID DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey, PUCHAR Base)
Definition: machpc.c:562
int Count
Definition: noreturn.cpp:7
@ SerialController
Definition: arc.h:130
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 749 of file machpc.c.

751{
752 PCSTR Option, c;
753 ULONG OptionLength, PortBitmap, i;
754
755 if (NtLdrGetOption(Options, "FASTDETECT"))
756 return (1 << MAX_COM_PORTS) - 1;
757
758 Option = NtLdrGetOptionEx(Options, "NOSERIALMICE=", &OptionLength);
759 if (!Option)
760 Option = NtLdrGetOptionEx(Options, "NOSERIALMICE:", &OptionLength);
761
762 if (!Option)
763 return 0;
764
765 /* Invalid port list */
766 if (OptionLength < (sizeof("NOSERIALMICE=COM9") - 1))
767 return (1 << MAX_COM_PORTS) - 1;
768
769 /* Move to the port list */
770 Option += sizeof("NOSERIALMICE=COM") - 1;
771 OptionLength -= sizeof("NOSERIALMICE=COM") - 1;
772
773 PortBitmap = 0;
774 c = Option;
775 for (i = 0; i < OptionLength; i += 2)
776 {
777 UCHAR PortNumber = *c - '0';
778
779 if (PortNumber > 0 && PortNumber <= 9)
780 PortBitmap |= 1 << (PortNumber - 1);
781
782 c += 2;
783 }
784
785 return PortBitmap;
786}
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 502 of file machpc.c.

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

Referenced by DetectSerialPointerPeripheral().

◆ InitializeSerialPort()

static VOID InitializeSerialPort ( PUCHAR  Port,
UCHAR  LineControl 
)
static

Definition at line 395 of file machpc.c.

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

Referenced by DetectSerialPointerPeripheral().

◆ MachInit()

VOID MachInit ( const char CmdLine)

Definition at line 1787 of file machpc.c.

1788{
1789 /* Setup vtbl */
1790 RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
1819
1821 PcVideoInit();
1822}
MACHVTBL MachVtbl
Definition: arcemul.c:21
BOOLEAN PcInitializeBootDevices(VOID)
Definition: hwdisk.c:458
VOID PcGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machpc.c:107
static UCHAR PcGetFloppyCount(VOID)
Definition: machpc.c:1688
PCONFIGURATION_COMPONENT_DATA PcHwDetect(_In_opt_ PCSTR Options)
Definition: machpc.c:1699
VOID PcHwIdle(VOID)
Definition: machpc.c:1729
VOID PcPrepareForReactOS(VOID)
Definition: machpc.c:1825
VOID PcBeep(VOID)
Definition: pcbeep.c:34
VOID PcConsPutChar(int Ch)
Definition: pccons.c:22
BOOLEAN PcConsKbHit(VOID)
Definition: pccons.c:63
int PcConsGetCh(void)
Definition: pccons.c:84
BOOLEAN PcDiskReadLogicalSectors(IN UCHAR DriveNumber, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
Definition: pcdisk.c:786
ULONG PcDiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: pcdisk.c:856
BOOLEAN PcDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: pcdisk.c:826
VOID HalpCalibrateStallExecution(VOID)
Definition: pchw.c:105
PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap(ULONG *MemoryMapSize)
Definition: pcmem.c:609
TIMEINFO * PcGetTime(VOID)
Definition: pcrtc.c:24
VOID PcVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
Definition: pcvideo.c:1161
BOOLEAN PcVideoIsPaletteFixed(VOID)
Definition: pcvideo.c:1261
VOID PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: pcvideo.c:1267
VOID PcVideoSync(VOID)
Definition: pcvideo.c:1285
VOID PcVideoGetFontsFromFirmware(PULONG RomFontPointers)
Definition: pcvideo.c:1127
VOID PcVideoInit(VOID)
Definition: pcvideo.c:1020
VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: pcvideo.c:1097
VOID PcVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: pcvideo.c:1276
VIDEODISPLAYMODE PcVideoSetDisplayMode(PCSTR DisplayModeName, BOOLEAN Init)
Definition: pcvideo.c:1045
ULONG PcVideoGetBufferSize(VOID)
Definition: pcvideo.c:1121
VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: pcvideo.c:1252
VOID PcVideoClearScreen(UCHAR Attr)
Definition: pcvideo.c:1236
VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: pcvideo.c:1195
VOID PcVideoHideShowTextCursor(BOOLEAN Show)
Definition: pcvideo.c:1186
VOID(* VideoGetPaletteColor)(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: machine.h:56
VIDEODISPLAYMODE(* VideoSetDisplayMode)(PCSTR DisplayMode, BOOLEAN Init)
Definition: machine.h:46
VOID(* GetExtendedBIOSData)(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machine.h:64
int(* ConsGetCh)(VOID)
Definition: machine.h:43
VOID(* PrepareForReactOS)(VOID)
Definition: machine.h:59
VOID(* VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: machine.h:55
BOOLEAN(* InitializeBootDevices)(VOID)
Definition: machine.h:76
VOID(* VideoCopyOffScreenBufferToVRAM)(PVOID Buffer)
Definition: machine.h:53
BOOLEAN(* ConsKbHit)(VOID)
Definition: machine.h:42
VOID(* VideoHideShowTextCursor)(BOOLEAN Show)
Definition: machine.h:51
TIMEINFO *(* GetTime)(VOID)
Definition: machine.h:72
UCHAR(* GetFloppyCount)(VOID)
Definition: machine.h:66
BOOLEAN(* DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry)
Definition: machine.h:68
BOOLEAN(* DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: machine.h:67
PFREELDR_MEMORY_DESCRIPTOR(* GetMemoryMap)(PULONG MaxMemoryMapSize)
Definition: machine.h:63
VOID(* VideoGetFontsFromFirmware)(PULONG RomFontPointers)
Definition: machine.h:49
VOID(* Beep)(VOID)
Definition: machine.h:58
VOID(* VideoSetTextCursorPosition)(UCHAR X, UCHAR Y)
Definition: machine.h:50
ULONG(* VideoGetBufferSize)(VOID)
Definition: machine.h:48
VOID(* VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: machine.h:52
ULONG(* DiskGetCacheableBlockCount)(UCHAR DriveNumber)
Definition: machine.h:69
VOID(* VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth)
Definition: machine.h:47
VOID(* VideoClearScreen)(UCHAR Attr)
Definition: machine.h:45
VOID(* HwIdle)(VOID)
Definition: machine.h:78
VOID(* VideoSync)(VOID)
Definition: machine.h:57
BOOLEAN(* VideoIsPaletteFixed)(VOID)
Definition: machine.h:54
PCONFIGURATION_COMPONENT_DATA(* HwDetect)(_In_opt_ PCSTR Options)
Definition: machine.h:77
VOID(* ConsPutChar)(int Ch)
Definition: machine.h:41

◆ PcGetExtendedBIOSData()

VOID PcGetExtendedBIOSData ( PULONG  ExtendedBIOSDataArea,
PULONG  ExtendedBIOSDataSize 
)

Definition at line 107 of file machpc.c.

108{
109 REGS BiosRegs;
110
111 /* Get address and size of the extended BIOS data area */
112 BiosRegs.d.eax = 0xC100;
113 Int386(0x15, &BiosRegs, &BiosRegs);
114 if (INT386_SUCCESS(BiosRegs))
115 {
116 *ExtendedBIOSDataArea = BiosRegs.w.es << 4;
117 *ExtendedBIOSDataSize = 1024;
118 }
119 else
120 {
121 WARN("Int 15h AH=C1h call failed\n");
124 }
125}
#define ExtendedBIOSDataArea
Definition: winldr.c:346
#define ExtendedBIOSDataSize
Definition: winldr.c:347
#define INT386_SUCCESS(regs)
Definition: pcbios.h:181
unsigned long eax
Definition: pcbios.h:93
DWORDREGS d
Definition: pcbios.h:163

Referenced by MachInit().

◆ PcGetFloppyCount()

static UCHAR PcGetFloppyCount ( VOID  )
static

Definition at line 1688 of file machpc.c.

1689{
1690 UCHAR Data;
1691
1692 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
1693 Data = READ_PORT_UCHAR((PUCHAR)0x71);
1694
1695 return ((Data & 0xF0) ? 1 : 0) + ((Data & 0x0F) ? 1 : 0);
1696}

Referenced by MachInit().

◆ PcGetHarddiskConfigurationData()

static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData ( UCHAR  DriveNumber,
ULONG pSize 
)
static

Definition at line 131 of file machpc.c.

132{
133 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
135 GEOMETRY Geometry;
136 ULONG Size;
137
138 /* Initialize returned size */
139 *pSize = 0;
140
141 /* Set 'Configuration Data' value */
144 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
145 if (PartialResourceList == NULL)
146 {
147 ERR("Failed to allocate resource descriptor\n");
148 return NULL;
149 }
150
151 RtlZeroMemory(PartialResourceList, Size);
152 PartialResourceList->Version = 1;
153 PartialResourceList->Revision = 1;
154 PartialResourceList->Count = 1;
155 PartialResourceList->PartialDescriptors[0].Type =
157// PartialResourceList->PartialDescriptors[0].ShareDisposition =
158// PartialResourceList->PartialDescriptors[0].Flags =
159 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
161
162 /* Get pointer to geometry data */
163 DiskGeometry = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
164
165 /* Get the disk geometry */
166 if (PcDiskGetDriveGeometry(DriveNumber, &Geometry))
167 {
168 DiskGeometry->BytesPerSector = Geometry.BytesPerSector;
169 DiskGeometry->NumberOfCylinders = Geometry.Cylinders;
170 DiskGeometry->SectorsPerTrack = Geometry.SectorsPerTrack;
171 DiskGeometry->NumberOfHeads = Geometry.Heads;
172 }
173 else
174 {
175 TRACE("Reading disk geometry failed\n");
176 FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
177 return NULL;
178 }
179 TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
180 DriveNumber,
181 DiskGeometry->NumberOfCylinders,
182 DiskGeometry->NumberOfHeads,
183 DiskGeometry->SectorsPerTrack,
184 DiskGeometry->BytesPerSector);
185
186 /* Return configuration data */
187 *pSize = Size;
188 return PartialResourceList;
189}
VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: heap.c:539
Definition: disk.h:26
ULONG BytesPerSector
Number of bytes per sector.
Definition: disk.h:30
ULONG Cylinders
Number of cylinders on the disk.
Definition: disk.h:27
ULONG SectorsPerTrack
Number of sectors per track.
Definition: disk.h:29
ULONG Heads
Number of heads on the disk.
Definition: disk.h:28
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 723 of file machpc.c.

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

Referenced by DetectIsaBios().

◆ PcHwDetect()

PCONFIGURATION_COMPONENT_DATA PcHwDetect ( _In_opt_ PCSTR  Options)

Definition at line 1699 of file machpc.c.

1701{
1703 ULONG BusNumber = 0;
1704
1705 TRACE("DetectHardware()\n");
1706
1707 /* Create the 'System' key */
1708 // TODO: Discover and set the other machine types
1709 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
1710
1713
1714 /* Detect buses */
1715 DetectPciBios(SystemKey, &BusNumber);
1716 DetectApmBios(SystemKey, &BusNumber);
1717 DetectPnpBios(SystemKey, &BusNumber);
1718 DetectIsaBios(Options, SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
1719 DetectAcpiBios(SystemKey, &BusNumber);
1720
1721 // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
1722 // CM_ROM_BLOCK data into the 'System' key's configuration data.
1723
1724 TRACE("DetectHardware() Done\n");
1725 return SystemKey;
1726}
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:59
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:257
static VOID DetectIsaBios(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA SystemKey, _Out_ ULONG *BusNumber)
Definition: machpc.c:1632
static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: machpc.c:131
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 1729 of file machpc.c.

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

Referenced by MachInit().

◆ PcPrepareForReactOS()

VOID PcPrepareForReactOS ( VOID  )

Definition at line 1825 of file machpc.c.

1826{
1827 /* Prepare video and turn off the floppy motor */
1830}
VOID __cdecl DiskStopFloppyMotor(VOID)
Definition: pc98hw.c:1235
VOID PcVideoPrepareForReactOS(VOID)
Definition: pcvideo.c:1308

Referenced by MachInit().

◆ PS2ControllerWait()

static VOID PS2ControllerWait ( VOID  )
static

Definition at line 1188 of file machpc.c.

1189{
1190 ULONG Timeout;
1191 UCHAR Status;
1192
1194 {
1197 return;
1198
1199 /* Sleep for one millisecond */
1201 }
1202}
#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().