ReactOS 0.4.16-dev-2293-g4d8327b
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 1737 of file machpc.c.

1740{
1741 REGS Regs;
1742
1743 RtlZeroMemory(&Regs, sizeof(Regs));
1744
1745 /* Set the boot drive and the boot partition */
1746 Regs.b.dl = (UCHAR)(BootDrive ? BootDrive : FrldrBootDrive);
1747 Regs.b.dh = (UCHAR)(BootPartition ? BootPartition : FrldrBootPartition);
1748
1749 /*
1750 * Don't stop the floppy drive motor when we are just booting a bootsector,
1751 * a drive, or a partition. If we were to stop the floppy motor, the BIOS
1752 * wouldn't be informed and if the next read is to a floppy then the BIOS
1753 * will still think the motor is on and this will result in a read error.
1754 */
1755 // DiskStopFloppyMotor();
1756
1757 Relocator16Boot(&Regs,
1758 /* Stack segment:pointer */
1759 0x0000, 0x7C00,
1760 /* Code segment:pointer */
1761 0x0000, 0x7C00);
1762}
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:104
ULONG FrldrBootPartition
Definition: uefidisk.c:105
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 1566 of file machpc.c.

1567{
1569 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1570 USHORT VesaVersion;
1571
1572 /* FIXME: Set 'ComponentInformation' value */
1573
1574 VesaVersion = BiosIsVesaSupported();
1575 if (VesaVersion != 0)
1576 {
1577 TRACE("VESA version %c.%c\n",
1578 (VesaVersion >> 8) + '0',
1579 (VesaVersion & 0xFF) + '0');
1580 }
1581 else
1582 {
1583 TRACE("VESA not supported\n");
1584 }
1585
1586 if (VesaVersion >= 0x0200)
1587 Identifier = "VBE Display";
1588 else
1589 Identifier = "VGA Display";
1590
1595 0,
1596 0xFFFFFFFF,
1597 Identifier,
1598 NULL,
1599 0,
1600 &ControllerKey);
1601
1602 /* FIXME: Add display peripheral (monitor) data */
1603 if (VesaVersion != 0)
1604 {
1606 {
1607 TRACE("VESA/DDC supported!\n");
1608 if (BiosVesaReadEdid())
1609 {
1610 TRACE("EDID data read successfully!\n");
1611 }
1612 }
1613 }
1614}
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 190 of file machpc.c.

192{
193 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
194 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
195 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
196 PDOCKING_STATE_INFORMATION DockingState;
197 PPNP_DOCK_INFO DockInfo;
199
201
202 /* Build full device descriptor */
203 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]) + sizeof(*DockingState);
204 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
205 if (PartialResourceList == NULL)
206 {
207 ERR("Failed to allocate resource descriptor\n");
208 return;
209 }
210
211 /* Initialize resource descriptor */
212 RtlZeroMemory(PartialResourceList, Size);
213 PartialResourceList->Version = 0;
214 PartialResourceList->Revision = 0;
215 PartialResourceList->Count = 1;
216
217 /* Set device specific data */
218 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
219 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
221 PartialDescriptor->Flags = 0;
222 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(*DockingState);
223
224 DockingState = (PDOCKING_STATE_INFORMATION)(PartialDescriptor + 1);
225 DockingState->ReturnCode = Result;
226 if (Result == 0)
227 {
228 DockInfo = (PPNP_DOCK_INFO)DiskReadBuffer;
229 DockingState->DockLocationID = DockInfo->DockLocationID;
230 DockingState->SerialNumber = DockInfo->SerialNumber;
231 DockingState->Capabilities = DockInfo->Capabilities;
232 TRACE("System docked\n");
233 TRACE("Location: 0x%08lx\n", DockInfo->DockLocationID);
234 TRACE("Serial: 0x%08lx\n", DockInfo->SerialNumber);
235 TRACE("Capabilities: 0x%04hx\n", DockInfo->Capabilities);
236 }
237
238 /* Create controller key */
242 0,
243 0,
244 0xFFFFFFFF,
245 "Docking State Information",
246 PartialResourceList,
247 Size,
248 &PeripheralKey);
249}
#define DiskReadBuffer
Definition: hardware.h:33
ULONG __cdecl PnpBiosGetDockStationInformation(UCHAR *DockingStationInfo)
PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: heap.c:533
struct _PNP_DOCK_INFO * PPNP_DOCK_INFO
struct _DOCKING_STATE_INFORMATION * PDOCKING_STATE_INFORMATION
#define CmResourceTypeDeviceSpecific
Definition: restypes.h:108
@ PeripheralClass
Definition: arc.h:104
@ DockingInformation
Definition: arc.h:151
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382::@391 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382 u
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
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
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 1618 of file machpc.c.

1622{
1623 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1625 ULONG Size;
1626
1627 /* Set 'Configuration Data' value */
1628 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors);
1629 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1630 if (PartialResourceList == NULL)
1631 {
1632 ERR("Failed to allocate resource descriptor\n");
1633 return;
1634 }
1635
1636 /* Initialize resource descriptor */
1637 RtlZeroMemory(PartialResourceList, Size);
1638 PartialResourceList->Version = 1;
1639 PartialResourceList->Revision = 1;
1640 PartialResourceList->Count = 0;
1641
1642 /* Create new bus key */
1643 FldrCreateComponentKey(SystemKey,
1646 0,
1647 0,
1648 0xFFFFFFFF,
1649 "ISA",
1650 PartialResourceList,
1651 Size,
1652 &BusKey);
1653
1654 /* Increment bus number */
1655 (*BusNumber)++;
1656
1657 /* Detect ISA/BIOS devices */
1658 DetectBiosDisks(SystemKey, BusKey);
1660 DetectParallelPorts(BusKey);
1662 DetectPS2Mouse(BusKey);
1663#if defined(_M_IX86)
1664 DetectBusMouse(BusKey);
1665#endif
1667
1668 /* FIXME: Detect more ISA devices */
1669}
static ULONG PcGetSerialPort(ULONG Index, PULONG Irq)
Definition: machpc.c:714
#define MAX_COM_PORTS
Definition: machpc.c:29
static VOID DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1108
static VOID DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1284
static VOID DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:883
VOID DetectSerialPorts(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA BusKey, _In_ GET_SERIAL_PORT MachGetSerialPort, _In_ ULONG Count)
Definition: machpc.c:780
static VOID DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1566
VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pchw.c:342
@ 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 1108 of file machpc.c.

1109{
1110 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1111 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
1112 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1113 ULONG Size;
1114
1115 /* Set 'Configuration Data' value */
1116 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[3]);
1117 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1118 if (PartialResourceList == NULL)
1119 {
1120 ERR("Failed to allocate resource descriptor\n");
1121 return;
1122 }
1123
1124 /* Initialize resource descriptor */
1125 RtlZeroMemory(PartialResourceList, Size);
1126 PartialResourceList->Version = 1;
1127 PartialResourceList->Revision = 1;
1128 PartialResourceList->Count = 3;
1129
1130 /* Set Interrupt */
1131 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1132 PartialDescriptor->Type = CmResourceTypeInterrupt;
1133 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1134 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1135 PartialDescriptor->u.Interrupt.Level = 1;
1136 PartialDescriptor->u.Interrupt.Vector = 1;
1137 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
1138
1139 /* Set IO Port 0x60 */
1140 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
1141 PartialDescriptor->Type = CmResourceTypePort;
1143 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1144 PartialDescriptor->u.Port.Start.LowPart = 0x60;
1145 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1146 PartialDescriptor->u.Port.Length = 1;
1147
1148 /* Set IO Port 0x64 */
1149 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
1150 PartialDescriptor->Type = CmResourceTypePort;
1152 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1153 PartialDescriptor->u.Port.Start.LowPart = 0x64;
1154 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1155 PartialDescriptor->u.Port.Length = 1;
1156
1157 /* Create controller key */
1161 Input | ConsoleIn,
1162 0,
1163 0xFFFFFFFF,
1164 NULL,
1165 PartialResourceList,
1166 Size,
1167 &ControllerKey);
1168
1169 DetectKeyboardPeripheral(ControllerKey);
1170}
static VOID DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: machpc.c:1044
#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::@382::@384 Port
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382::@385 Interrupt
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241

Referenced by DetectIsaBios().

◆ DetectKeyboardDevice()

BOOLEAN DetectKeyboardDevice ( VOID  )

Definition at line 975 of file machpc.c.

976{
978 UCHAR Scancode;
979 ULONG Loops;
981
982 /* Identify device */
984
985 /* Wait for reply */
986 for (Loops = 0; Loops < 100; Loops++)
987 {
991 break;
992 }
993
995 {
996 /* PC/XT keyboard or no keyboard */
997 Result = FALSE;
998 }
999
1001 if (Scancode != 0xFA)
1002 {
1003 /* No ACK received */
1004 Result = FALSE;
1005 }
1006
1008
1011 {
1012 /* Found AT keyboard */
1013 return Result;
1014 }
1015
1017 if (Scancode != 0xAB)
1018 {
1019 /* No 0xAB received */
1020 Result = FALSE;
1021 }
1022
1024
1027 {
1028 /* No byte in buffer */
1029 Result = FALSE;
1030 }
1031
1033 if (Scancode != 0x41)
1034 {
1035 /* No 0x41 received */
1036 Result = FALSE;
1037 }
1038
1039 /* Found MF-II keyboard */
1040 return Result;
1041}
unsigned char BOOLEAN
Definition: actypes.h:127
#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 1044 of file machpc.c.

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

Referenced by DetectKeyboardController().

◆ DetectParallelPorts()

static VOID DetectParallelPorts ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 883 of file machpc.c.

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

254{
255 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
259 ULONG x;
260 ULONG NodeSize = 0;
261 ULONG NodeCount = 0;
263 ULONG FoundNodeCount;
264 int i;
265 ULONG PnpBufferSize;
266 ULONG PnpBufferSizeLimit;
267 ULONG Size;
268 char* Ptr;
269
271 if (InstData == NULL || strncmp((CHAR*)InstData->Signature, "$PnP", 4))
272 {
273 TRACE("PnP-BIOS not supported\n");
274 return;
275 }
276
277 TRACE("PnP-BIOS supported\n");
278 TRACE("Signature '%c%c%c%c'\n",
279 InstData->Signature[0], InstData->Signature[1],
280 InstData->Signature[2], InstData->Signature[3]);
281
282 x = PnpBiosGetDeviceNodeCount(&NodeSize, &NodeCount);
283 if (x == 0x82)
284 {
285 TRACE("PnP-BIOS function 'Get Number of System Device Nodes' not supported\n");
286 return;
287 }
288
289 NodeCount &= 0xFF; // needed since some fscked up BIOSes return wrong info (e.g. Mac Virtual PC)
290 // e.g. look: https://web.archive.org/web/20080329010332/http://my.execpc.com/~geezer/osd/pnp/pnp16.c
291 if (x != 0 || NodeSize == 0 || NodeCount == 0)
292 {
293 ERR("PnP-BIOS failed to enumerate device nodes\n");
294 return;
295 }
296 TRACE("MaxNodeSize %u NodeCount %u\n", NodeSize, NodeCount);
297 TRACE("Estimated buffer size %u\n", NodeSize * NodeCount);
298
299 /* Set 'Configuration Data' value */
300 PnpBufferSizeLimit = sizeof(*InstData) + (NodeSize * NodeCount);
301 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]) + PnpBufferSizeLimit;
302 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
303 if (PartialResourceList == NULL)
304 {
305 ERR("Failed to allocate resource descriptor\n");
306 return;
307 }
308
309 /* Initialize resource descriptor */
310 RtlZeroMemory(PartialResourceList, Size);
311 PartialResourceList->Version = 1;
312 PartialResourceList->Revision = 1;
313 PartialResourceList->Count = 1;
314 PartialResourceList->PartialDescriptors[0].Type =
316 PartialResourceList->PartialDescriptors[0].ShareDisposition =
318
319 /* Set installation check data */
320 Ptr = (char*)&PartialResourceList->PartialDescriptors[1];
321 RtlCopyMemory(Ptr, InstData, sizeof(*InstData));
322 Ptr += sizeof(*InstData);
323 PnpBufferSize = sizeof(*InstData);
324
325 /* Copy device nodes */
326 FoundNodeCount = 0;
327 for (i = 0; i < 0xFF; i++)
328 {
329 NodeNumber = (UCHAR)i;
330
332 if (x == 0)
333 {
335
336 TRACE("Node: %u Size %u (0x%x)\n",
337 DeviceNode->Node,
338 DeviceNode->Size,
339 DeviceNode->Size);
340
341 if (PnpBufferSize + DeviceNode->Size > PnpBufferSizeLimit)
342 {
343 ERR("Buffer too small! Ignoring remaining device nodes. (i = %d)\n", i);
344 break;
345 }
346
348
349 Ptr += DeviceNode->Size;
350 PnpBufferSize += DeviceNode->Size;
351
352 FoundNodeCount++;
353 if (FoundNodeCount >= NodeCount)
354 break;
355 }
356 }
357
358 /* Set real data size */
359 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
360 PnpBufferSize;
361 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]) + PnpBufferSize;
362
363 TRACE("Real buffer size: %u\n", PnpBufferSize);
364 TRACE("Resource size: %u\n", Size);
365
366 /* Create component key */
367 FldrCreateComponentKey(SystemKey,
370 0,
371 0,
372 0xFFFFFFFF,
373 "PNP BIOS",
374 PartialResourceList,
375 Size,
376 &BusKey);
377
378 DetectDockingStation(BusKey);
379
380 (*BusNumber)++;
381}
@ 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:190
struct _CM_PNP_BIOS_INSTALLATION_CHECK * PCM_PNP_BIOS_INSTALLATION_CHECK
struct _CM_PNP_BIOS_DEVICE_NODE * PCM_PNP_BIOS_DEVICE_NODE
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Out_ PUSHORT NodeNumber
Definition: iofuncs.h:2574

Referenced by PcHwDetect().

◆ DetectPS2AuxDevice()

static BOOLEAN DetectPS2AuxDevice ( VOID  )
static

Definition at line 1235 of file machpc.c.

1236{
1237 UCHAR Scancode;
1238 UCHAR Status;
1239 ULONG Loops;
1241
1246
1247 /* Identify device */
1249
1250 /* Wait for reply */
1251 for (Loops = 0; Loops < 100; Loops++)
1252 {
1256 break;
1257 }
1258
1261 Result = FALSE;
1262
1264 if (Scancode != 0xFA)
1265 Result = FALSE;
1266
1268
1271 Result = FALSE;
1272
1274 if (Scancode != 0x00)
1275 Result = FALSE;
1276
1277 return Result;
1278}
#define CONTROLLER_COMMAND_WRITE_MOUSE
Definition: machpc.c:77
static VOID PS2ControllerWait(VOID)
Definition: machpc.c:1174
#define CONTROLLER_REGISTER_CONTROL
Definition: machpc.c:62

Referenced by DetectPS2Mouse().

◆ DetectPS2AuxPort()

static BOOLEAN DetectPS2AuxPort ( VOID  )
static

Definition at line 1192 of file machpc.c.

1193{
1194#if 1
1195 /* Current detection is too unreliable. Just do as if
1196 * the PS/2 aux port is always present
1197 */
1198 return TRUE;
1199#else
1200 ULONG Loops;
1201 UCHAR Status;
1202
1203 /* Put the value 0x5A in the output buffer using the
1204 * "WriteAuxiliary Device Output Buffer" command (0xD3).
1205 * Poll the Status Register for a while to see if the value really turns up
1206 * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1207 * to 1 in the Status Register, we assume this controller has an
1208 * Auxiliary Port (a.k.a. Mouse Port).
1209 */
1214
1215 /* 0x5A is a random dummy value */
1217 0x5A);
1218
1219 for (Loops = 0; Loops < 10; Loops++)
1220 {
1224 break;
1225 }
1226
1228
1230#endif
1231}
#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 1284 of file machpc.c.

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

Referenced by DetectIsaBios().

◆ DetectSerialMouse()

static ULONG DetectSerialMouse ( PUCHAR  Port)
static

Definition at line 401 of file machpc.c.

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

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

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

Referenced by DetectIsaBios().

◆ GetSerialMouseDetectionBitmap()

static ULONG GetSerialMouseDetectionBitmap ( _In_opt_ PCSTR  Options)
static

Definition at line 740 of file machpc.c.

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

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

Referenced by DetectSerialPointerPeripheral().

◆ InitializeSerialPort()

static VOID InitializeSerialPort ( PUCHAR  Port,
UCHAR  LineControl 
)
static

Definition at line 387 of file machpc.c.

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

Referenced by DetectSerialPointerPeripheral().

◆ MachInit()

VOID MachInit ( const char CmdLine)

Definition at line 1772 of file machpc.c.

1773{
1774 /* Setup vtbl */
1775 RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
1804
1806 PcVideoInit();
1807}
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:1673
PCONFIGURATION_COMPONENT_DATA PcHwDetect(_In_opt_ PCSTR Options)
Definition: machpc.c:1684
VOID PcHwIdle(VOID)
Definition: machpc.c:1714
VOID PcPrepareForReactOS(VOID)
Definition: machpc.c:1810
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:30
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 1673 of file machpc.c.

1674{
1675 UCHAR Data;
1676
1677 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
1678 Data = READ_PORT_UCHAR((PUCHAR)0x71);
1679
1680 return ((Data & 0xF0) ? 1 : 0) + ((Data & 0x0F) ? 1 : 0);
1681}

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 */
142 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]) + sizeof(*DiskGeometry);
143 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
144 if (PartialResourceList == NULL)
145 {
146 ERR("Failed to allocate resource descriptor\n");
147 return NULL;
148 }
149
150 RtlZeroMemory(PartialResourceList, Size);
151 PartialResourceList->Version = 1;
152 PartialResourceList->Revision = 1;
153 PartialResourceList->Count = 1;
154 PartialResourceList->PartialDescriptors[0].Type =
156// PartialResourceList->PartialDescriptors[0].ShareDisposition =
157// PartialResourceList->PartialDescriptors[0].Flags =
158 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
159 sizeof(*DiskGeometry);
160
161 /* Get the disk geometry */
162 DiskGeometry = (PCM_DISK_GEOMETRY_DEVICE_DATA)&PartialResourceList->PartialDescriptors[1];
163 if (PcDiskGetDriveGeometry(DriveNumber, &Geometry))
164 {
165 DiskGeometry->BytesPerSector = Geometry.BytesPerSector;
166 DiskGeometry->NumberOfCylinders = Geometry.Cylinders;
167 DiskGeometry->SectorsPerTrack = Geometry.SectorsPerTrack;
168 DiskGeometry->NumberOfHeads = Geometry.Heads;
169 }
170 else
171 {
172 TRACE("Reading disk geometry failed\n");
173 FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
174 return NULL;
175 }
176 TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
177 DriveNumber,
178 DiskGeometry->NumberOfCylinders,
179 DiskGeometry->NumberOfHeads,
180 DiskGeometry->SectorsPerTrack,
181 DiskGeometry->BytesPerSector);
182
183 /* Return configuration data */
184 *pSize = Size;
185 return PartialResourceList;
186}
VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: heap.c:539
if(dx< 0)
Definition: linetemp.h:194
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
struct _CM_DISK_GEOMETRY_DEVICE_DATA * PCM_DISK_GEOMETRY_DEVICE_DATA

Referenced by PcHwDetect().

◆ PcGetSerialPort()

static ULONG PcGetSerialPort ( ULONG  Index,
PULONG  Irq 
)
static

Definition at line 714 of file machpc.c.

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

Referenced by DetectIsaBios().

◆ PcHwDetect()

PCONFIGURATION_COMPONENT_DATA PcHwDetect ( _In_opt_ PCSTR  Options)

Definition at line 1684 of file machpc.c.

1686{
1688 ULONG BusNumber = 0;
1689
1690 TRACE("DetectHardware()\n");
1691
1692 /* Create the 'System' key */
1693 // TODO: Discover and set the other machine types
1694 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
1695
1698
1699 /* Detect buses */
1700 DetectPciBios(SystemKey, &BusNumber);
1701 DetectApmBios(SystemKey, &BusNumber);
1702 DetectPnpBios(SystemKey, &BusNumber);
1703 DetectIsaBios(Options, SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
1704 DetectAcpiBios(SystemKey, &BusNumber);
1705
1706 // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
1707 // CM_ROM_BLOCK data into the 'System' key's configuration data.
1708
1709 TRACE("DetectHardware() Done\n");
1710 return SystemKey;
1711}
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:174
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:253
static VOID DetectIsaBios(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA SystemKey, _Out_ ULONG *BusNumber)
Definition: machpc.c:1618
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 1714 of file machpc.c.

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

Referenced by MachInit().

◆ PcPrepareForReactOS()

VOID PcPrepareForReactOS ( VOID  )

Definition at line 1810 of file machpc.c.

1811{
1812 /* Prepare video and turn off the floppy motor */
1815}
VOID __cdecl DiskStopFloppyMotor(VOID)
Definition: pc98hw.c:1217
VOID PcVideoPrepareForReactOS(VOID)
Definition: pcvideo.c:1308

Referenced by MachInit().

◆ PS2ControllerWait()

static VOID PS2ControllerWait ( VOID  )
static

Definition at line 1174 of file machpc.c.

1175{
1176 ULONG Timeout;
1177 UCHAR Status;
1178
1180 {
1183 return;
1184
1185 /* Sleep for one millisecond */
1187 }
1188}
#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().