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

Go to the source code of this file.

Macros

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

Functions

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

Macro Definition Documentation

◆ AUX_STATUS_OUTPUT_BUFFER_FULL

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

Definition at line 88 of file machpc.c.

◆ CONTROLLER_COMMAND_GET_VERSION

#define CONTROLLER_COMMAND_GET_VERSION   0xA1

Definition at line 68 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_DISABLE

#define CONTROLLER_COMMAND_KEYBOARD_DISABLE   0xAD

Definition at line 74 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_ENABLE

#define CONTROLLER_COMMAND_KEYBOARD_ENABLE   0xAE

Definition at line 75 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_TEST

#define CONTROLLER_COMMAND_KEYBOARD_TEST   0xAB

Definition at line 73 of file machpc.c.

◆ CONTROLLER_COMMAND_MOUSE_DISABLE

#define CONTROLLER_COMMAND_MOUSE_DISABLE   0xA7

Definition at line 69 of file machpc.c.

◆ CONTROLLER_COMMAND_MOUSE_ENABLE

#define CONTROLLER_COMMAND_MOUSE_ENABLE   0xA8

Definition at line 70 of file machpc.c.

◆ CONTROLLER_COMMAND_READ_MODE

#define CONTROLLER_COMMAND_READ_MODE   0x20

Definition at line 66 of file machpc.c.

◆ CONTROLLER_COMMAND_SELF_TEST

#define CONTROLLER_COMMAND_SELF_TEST   0xAA

Definition at line 72 of file machpc.c.

◆ CONTROLLER_COMMAND_TEST_MOUSE

#define CONTROLLER_COMMAND_TEST_MOUSE   0xA9

Definition at line 71 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MODE

#define CONTROLLER_COMMAND_WRITE_MODE   0x60

Definition at line 67 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MOUSE

#define CONTROLLER_COMMAND_WRITE_MOUSE   0xD4

Definition at line 77 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER

#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER   0xD3

Definition at line 76 of file machpc.c.

◆ CONTROLLER_REGISTER_CONTROL

#define CONTROLLER_REGISTER_CONTROL   0x64

Definition at line 62 of file machpc.c.

◆ CONTROLLER_REGISTER_DATA

#define CONTROLLER_REGISTER_DATA   0x60

Definition at line 63 of file machpc.c.

◆ CONTROLLER_REGISTER_STATUS

#define CONTROLLER_REGISTER_STATUS   0x64

Definition at line 61 of file machpc.c.

◆ CONTROLLER_STATUS_COMMAND

#define CONTROLLER_STATUS_COMMAND   0x08

Definition at line 83 of file machpc.c.

◆ CONTROLLER_STATUS_GENERAL_TIMEOUT

#define CONTROLLER_STATUS_GENERAL_TIMEOUT   0x40

Definition at line 86 of file machpc.c.

◆ CONTROLLER_STATUS_INPUT_BUFFER_FULL

#define CONTROLLER_STATUS_INPUT_BUFFER_FULL   0x02

Definition at line 81 of file machpc.c.

◆ CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL

#define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL   0x20

Definition at line 85 of file machpc.c.

◆ CONTROLLER_STATUS_OUTPUT_BUFFER_FULL

#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL   0x01

Definition at line 80 of file machpc.c.

◆ CONTROLLER_STATUS_PARITY_ERROR

#define CONTROLLER_STATUS_PARITY_ERROR   0x80

Definition at line 87 of file machpc.c.

◆ CONTROLLER_STATUS_SELF_TEST

#define CONTROLLER_STATUS_SELF_TEST   0x04

Definition at line 82 of file machpc.c.

◆ CONTROLLER_STATUS_UNLOCKED

#define CONTROLLER_STATUS_UNLOCKED   0x10

Definition at line 84 of file machpc.c.

◆ CONTROLLER_TIMEOUT

#define CONTROLLER_TIMEOUT   250

Definition at line 92 of file machpc.c.

◆ INPORT_MODE_BASE

#define INPORT_MODE_BASE   0x10

Definition at line 49 of file machpc.c.

◆ INPORT_REG_MODE

#define INPORT_REG_MODE   0x07

Definition at line 47 of file machpc.c.

◆ INPORT_REGISTER_CONTROL

#define INPORT_REGISTER_CONTROL   0x00

Definition at line 43 of file machpc.c.

◆ INPORT_REGISTER_DATA

#define INPORT_REGISTER_DATA   0x01

Definition at line 44 of file machpc.c.

◆ INPORT_REGISTER_SIGNATURE

#define INPORT_REGISTER_SIGNATURE   0x02

Definition at line 45 of file machpc.c.

◆ INPORT_RESET

#define INPORT_RESET   0x80

Definition at line 48 of file machpc.c.

◆ INPORT_SIGNATURE

#define INPORT_SIGNATURE   0xDE

Definition at line 51 of file machpc.c.

◆ INPORT_TEST_IRQ

#define INPORT_TEST_IRQ   0x16

Definition at line 50 of file machpc.c.

◆ MAX_COM_PORTS

#define MAX_COM_PORTS   4

Definition at line 29 of file machpc.c.

◆ MAX_LPT_PORTS

#define MAX_LPT_PORTS   3

Definition at line 30 of file machpc.c.

◆ MOUSE_TYPE_LOGITECH

#define MOUSE_TYPE_LOGITECH   2

Definition at line 37 of file machpc.c.

◆ MOUSE_TYPE_MICROSOFT

#define MOUSE_TYPE_MICROSOFT   1

Definition at line 35 of file machpc.c.

◆ MOUSE_TYPE_MOUSESYSTEMS

#define MOUSE_TYPE_MOUSESYSTEMS   4

Definition at line 41 of file machpc.c.

◆ MOUSE_TYPE_NONE

#define MOUSE_TYPE_NONE   0

Definition at line 33 of file machpc.c.

◆ MOUSE_TYPE_WHEELZ

#define MOUSE_TYPE_WHEELZ   3

Definition at line 39 of file machpc.c.

◆ PIC1_CONTROL_PORT

#define PIC1_CONTROL_PORT   0x20

Definition at line 53 of file machpc.c.

◆ PIC1_DATA_PORT

#define PIC1_DATA_PORT   0x21

Definition at line 54 of file machpc.c.

◆ PIC2_CONTROL_PORT

#define PIC2_CONTROL_PORT   0xA0

Definition at line 55 of file machpc.c.

◆ PIC2_DATA_PORT

#define PIC2_DATA_PORT   0xA1

Definition at line 56 of file machpc.c.

Function Documentation

◆ BiosIsVesaDdcSupported()

BOOLEAN BiosIsVesaDdcSupported ( VOID  )

Definition at line 242 of file pcvesa.c.

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

Referenced by DetectDisplayController().

◆ BiosIsVesaSupported()

USHORT BiosIsVesaSupported ( VOID  )

Definition at line 160 of file pcvesa.c.

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

Referenced by DetectDisplayController().

◆ BiosVesaReadEdid()

BOOLEAN BiosVesaReadEdid ( VOID  )

Definition at line 272 of file pcvesa.c.

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

Referenced by DetectDisplayController().

◆ ChainLoadBiosBootSectorCode()

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

Definition at line 1729 of file machpc.c.

1732{
1733 REGS Regs;
1734
1735 RtlZeroMemory(&Regs, sizeof(Regs));
1736
1737 /* Set the boot drive and the boot partition */
1738 Regs.b.dl = (UCHAR)(BootDrive ? BootDrive : FrldrBootDrive);
1739 Regs.b.dh = (UCHAR)(BootPartition ? BootPartition : FrldrBootPartition);
1740
1741 /*
1742 * Don't stop the floppy drive motor when we are just booting a bootsector,
1743 * a drive, or a partition. If we were to stop the floppy motor, the BIOS
1744 * wouldn't be informed and if the next read is to a floppy then the BIOS
1745 * will still think the motor is on and this will result in a read error.
1746 */
1747 // DiskStopFloppyMotor();
1748
1749 Relocator16Boot(&Regs,
1750 /* Stack segment:pointer */
1751 0x0000, 0x7C00,
1752 /* Code segment:pointer */
1753 0x0000, 0x7C00);
1754}
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:140
unsigned char dh
Definition: pcbios.h:141
UCHAR FrldrBootDrive
Definition: uefidisk.c:47
ULONG FrldrBootPartition
Definition: uefidisk.c:48
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( HWDETECT  )

◆ DetectDisplayController()

static VOID DetectDisplayController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1554 of file machpc.c.

1555{
1557 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1558 USHORT VesaVersion;
1559
1560 /* FIXME: Set 'ComponentInformation' value */
1561
1562 VesaVersion = BiosIsVesaSupported();
1563 if (VesaVersion != 0)
1564 {
1565 TRACE("VESA version %c.%c\n",
1566 (VesaVersion >> 8) + '0',
1567 (VesaVersion & 0xFF) + '0');
1568 }
1569 else
1570 {
1571 TRACE("VESA not supported\n");
1572 }
1573
1574 if (VesaVersion >= 0x0200)
1575 Identifier = "VBE Display";
1576 else
1577 Identifier = "VGA Display";
1578
1583 0,
1584 0xFFFFFFFF,
1585 Identifier,
1586 NULL,
1587 0,
1588 &ControllerKey);
1589
1590 /* FIXME: Add display peripheral (monitor) data */
1591 if (VesaVersion != 0)
1592 {
1594 {
1595 TRACE("VESA/DDC supported!\n");
1596 if (BiosVesaReadEdid())
1597 {
1598 TRACE("EDID data read successfully!\n");
1599 }
1600 }
1601 }
1602}
VOID FldrCreateComponentKey(_In_ PCONFIGURATION_COMPONENT_DATA SystemNode, _In_ CONFIGURATION_CLASS Class, _In_ CONFIGURATION_TYPE Type, _In_ IDENTIFIER_FLAG Flags, _In_ ULONG Key, _In_ ULONG Affinity, _In_ PCSTR IdentifierString, _In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _In_ ULONG Size, _Out_ PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:198
@ Identifier
Definition: asmpp.cpp:95
#define NULL
Definition: types.h:112
BOOLEAN BiosVesaReadEdid(VOID)
Definition: pcvesa.c:272
BOOLEAN BiosIsVesaDdcSupported(VOID)
Definition: pcvesa.c:242
USHORT BiosIsVesaSupported(VOID)
Definition: pcvesa.c:160
unsigned short USHORT
Definition: pedump.c:61
@ ControllerClass
Definition: arc.h:94
@ DisplayController
Definition: arc.h:123
@ ConsoleOut
Definition: arc.h:83
@ Output
Definition: arc.h:85
const char * PCSTR
Definition: typedefs.h:52

Referenced by DetectIsaBios().

◆ DetectDockingStation()

static VOID DetectDockingStation ( _Inout_ PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 182 of file machpc.c.

184{
185 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
186 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
187 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
188 PDOCKING_STATE_INFORMATION DockingState;
190
192
193 /* Build full device descriptor */
196 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
197 if (PartialResourceList == NULL)
198 {
199 ERR("Failed to allocate resource descriptor\n");
200 return;
201 }
202
203 /* Initialize resource descriptor */
204 RtlZeroMemory(PartialResourceList, Size);
205 PartialResourceList->Version = 0;
206 PartialResourceList->Revision = 0;
207 PartialResourceList->Count = 1;
208
209 /* Set device specific data */
210 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
211 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
213 PartialDescriptor->Flags = 0;
214 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(DOCKING_STATE_INFORMATION);
215
216 DockingState = (PDOCKING_STATE_INFORMATION)&PartialResourceList->PartialDescriptors[1];
217 DockingState->ReturnCode = Result;
218 if (Result == 0)
219 {
220 /* FIXME: Add more device specific data */
221 ERR("FIXME: System docked\n");
222 }
223
224 /* Create controller key */
228 0,
229 0,
230 0xFFFFFFFF,
231 "Docking State Information",
232 PartialResourceList,
233 Size,
234 &PeripheralKey);
235}
#define DiskReadBuffer
Definition: hardware.h:33
ULONG __cdecl PnpBiosGetDockStationInformation(UCHAR *DockingStationInfo)
PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: heap.c:533
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
if(dx< 0)
Definition: linetemp.h:194
struct _DOCKING_STATE_INFORMATION DOCKING_STATE_INFORMATION
struct _DOCKING_STATE_INFORMATION * PDOCKING_STATE_INFORMATION
@ PeripheralClass
Definition: arc.h:95
@ DockingInformation
Definition: arc.h:142
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@423::@432 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@423 u
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
uint32_t ULONG
Definition: typedefs.h:59
#define TAG_HW_RESOURCE_LIST
Definition: uefidisk.c:15
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
@ CmResourceShareUndetermined
Definition: cmtypes.h:240

Referenced by DetectPnpBios().

◆ DetectIsaBios()

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

Definition at line 1606 of file machpc.c.

1610{
1611 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1613 ULONG Size;
1614
1615 /* Set 'Configuration Data' value */
1616 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1618 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1619 if (PartialResourceList == NULL)
1620 {
1621 ERR("Failed to allocate resource descriptor\n");
1622 return;
1623 }
1624
1625 /* Initialize resource descriptor */
1626 RtlZeroMemory(PartialResourceList, Size);
1627 PartialResourceList->Version = 1;
1628 PartialResourceList->Revision = 1;
1629 PartialResourceList->Count = 0;
1630
1631 /* Create new bus key */
1632 FldrCreateComponentKey(SystemKey,
1635 0,
1636 0,
1637 0xFFFFFFFF,
1638 "ISA",
1639 PartialResourceList,
1640 Size,
1641 &BusKey);
1642
1643 /* Increment bus number */
1644 (*BusNumber)++;
1645
1646 /* Detect ISA/BIOS devices */
1647 DetectBiosDisks(SystemKey, BusKey);
1649 DetectParallelPorts(BusKey);
1651 DetectPS2Mouse(BusKey);
1652#if defined(_M_IX86)
1653 DetectBusMouse(BusKey);
1654#endif
1656
1657 /* FIXME: Detect more ISA devices */
1658}
static ULONG PcGetSerialPort(ULONG Index, PULONG Irq)
Definition: machpc.c:701
#define MAX_COM_PORTS
Definition: machpc.c:29
static VOID DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1095
static VOID DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1272
static VOID DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:869
VOID DetectSerialPorts(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA BusKey, _In_ GET_SERIAL_PORT MachGetSerialPort, _In_ ULONG Count)
Definition: machpc.c:766
static VOID DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1554
VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pchw.c:344
@ AdapterClass
Definition: arc.h:93
@ MultiFunctionAdapter
Definition: arc.h:116
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534

Referenced by PcHwDetect().

◆ DetectKeyboardController()

static VOID DetectKeyboardController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1095 of file machpc.c.

1096{
1097 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1098 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
1099 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1100 ULONG Size;
1101
1102 /* Set 'Configuration Data' value */
1103 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
1105 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1106 if (PartialResourceList == NULL)
1107 {
1108 ERR("Failed to allocate resource descriptor\n");
1109 return;
1110 }
1111
1112 /* Initialize resource descriptor */
1113 RtlZeroMemory(PartialResourceList, Size);
1114 PartialResourceList->Version = 1;
1115 PartialResourceList->Revision = 1;
1116 PartialResourceList->Count = 3;
1117
1118 /* Set Interrupt */
1119 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1120 PartialDescriptor->Type = CmResourceTypeInterrupt;
1121 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1122 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1123 PartialDescriptor->u.Interrupt.Level = 1;
1124 PartialDescriptor->u.Interrupt.Vector = 1;
1125 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
1126
1127 /* Set IO Port 0x60 */
1128 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
1129 PartialDescriptor->Type = CmResourceTypePort;
1131 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1132 PartialDescriptor->u.Port.Start.LowPart = 0x60;
1133 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1134 PartialDescriptor->u.Port.Length = 1;
1135
1136 /* Set IO Port 0x64 */
1137 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
1138 PartialDescriptor->Type = CmResourceTypePort;
1140 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1141 PartialDescriptor->u.Port.Start.LowPart = 0x64;
1142 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1143 PartialDescriptor->u.Port.Length = 1;
1144
1145 /* Create controller key */
1149 Input | ConsoleIn,
1150 0,
1151 0xFFFFFFFF,
1152 NULL,
1153 PartialResourceList,
1154 Size,
1155 &ControllerKey);
1156
1157 DetectKeyboardPeripheral(ControllerKey);
1158}
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
static VOID DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: machpc.c:1030
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
@ KeyboardController
Definition: arc.h:126
@ ConsoleIn
Definition: arc.h:82
@ Input
Definition: arc.h:84
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@423::@426 Interrupt
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@423::@425 Port
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241

Referenced by DetectIsaBios().

◆ DetectKeyboardDevice()

BOOLEAN DetectKeyboardDevice ( VOID  )

Definition at line 961 of file machpc.c.

962{
964 UCHAR Scancode;
965 ULONG Loops;
967
968 /* Identify device */
970
971 /* Wait for reply */
972 for (Loops = 0; Loops < 100; Loops++)
973 {
977 break;
978 }
979
981 {
982 /* PC/XT keyboard or no keyboard */
983 Result = FALSE;
984 }
985
987 if (Scancode != 0xFA)
988 {
989 /* No ACK received */
990 Result = FALSE;
991 }
992
994
997 {
998 /* Found AT keyboard */
999 return Result;
1000 }
1001
1003 if (Scancode != 0xAB)
1004 {
1005 /* No 0xAB received */
1006 Result = FALSE;
1007 }
1008
1010
1013 {
1014 /* No byte in buffer */
1015 Result = FALSE;
1016 }
1017
1019 if (Scancode != 0x41)
1020 {
1021 /* No 0x41 received */
1022 Result = FALSE;
1023 }
1024
1025 /* Found MF-II keyboard */
1026 return Result;
1027}
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 1030 of file machpc.c.

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

Referenced by DetectKeyboardController().

◆ DetectParallelPorts()

static VOID DetectParallelPorts ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 869 of file machpc.c.

870{
871 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
872 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
873 ULONG Irq[MAX_LPT_PORTS] = {7, 5, (ULONG) - 1};
874 CHAR Identifier[80];
875 PCONFIGURATION_COMPONENT_DATA ControllerKey;
876 PUSHORT BasePtr;
877 ULONG Base;
878 ULONG ControllerNumber = 0;
879 ULONG i;
880 ULONG Size;
881
882 TRACE("DetectParallelPorts() called\n");
883
884 /*
885 * The BIOS data area 0x408 holds the address of the first valid LPT port.
886 * Each LPT port address is stored in a 2-byte field.
887 * Infos at: https://web.archive.org/web/20240119203029/http://www.bioscentral.com/misc/bda.htm
888 */
889 BasePtr = (PUSHORT)0x408;
890
891 for (i = 0; i < MAX_LPT_PORTS; i++, BasePtr++)
892 {
893 Base = (ULONG) * BasePtr;
894 if (Base == 0)
895 continue;
896
897 TRACE("Parallel port %u: %x\n", ControllerNumber, Base);
898
899 /* Set 'Identifier' value */
900 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "PARALLEL%ld", i + 1);
901
902 /* Build full device descriptor */
904 if (Irq[i] != (ULONG) - 1)
906
907 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
908 if (PartialResourceList == NULL)
909 {
910 ERR("Failed to allocate resource descriptor! Ignoring remaining parallel ports. (i = %lu)\n", i);
911 break;
912 }
913
914 /* Initialize resource descriptor */
915 RtlZeroMemory(PartialResourceList, Size);
916 PartialResourceList->Version = 1;
917 PartialResourceList->Revision = 1;
918 PartialResourceList->Count = (Irq[i] != (ULONG) - 1) ? 2 : 1;
919
920 /* Set IO Port */
921 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
922 PartialDescriptor->Type = CmResourceTypePort;
924 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
925 PartialDescriptor->u.Port.Start.LowPart = Base;
926 PartialDescriptor->u.Port.Start.HighPart = 0x0;
927 PartialDescriptor->u.Port.Length = 3;
928
929 /* Set Interrupt */
930 if (Irq[i] != (ULONG) - 1)
931 {
932 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
933 PartialDescriptor->Type = CmResourceTypeInterrupt;
935 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
936 PartialDescriptor->u.Interrupt.Level = Irq[i];
937 PartialDescriptor->u.Interrupt.Vector = Irq[i];
938 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
939 }
940
941 /* Create controller key */
945 Output,
946 ControllerNumber,
947 0xFFFFFFFF,
949 PartialResourceList,
950 Size,
951 &ControllerKey);
952
953 ControllerNumber++;
954 }
955
956 TRACE("DetectParallelPorts() done\n");
957}
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:2478
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
@ ParallelController
Definition: arc.h:124
uint16_t * PUSHORT
Definition: typedefs.h:56
char CHAR
Definition: xmlstorage.h:175

Referenced by DetectIsaBios().

◆ DetectPnpBios()

static VOID DetectPnpBios ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
ULONG BusNumber 
)
static

Definition at line 239 of file machpc.c.

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

1224{
1225 UCHAR Scancode;
1226 UCHAR Status;
1227 ULONG Loops;
1229
1234
1235 /* Identify device */
1237
1238 /* Wait for reply */
1239 for (Loops = 0; Loops < 100; Loops++)
1240 {
1244 break;
1245 }
1246
1249 Result = FALSE;
1250
1252 if (Scancode != 0xFA)
1253 Result = FALSE;
1254
1256
1259 Result = FALSE;
1260
1262 if (Scancode != 0x00)
1263 Result = FALSE;
1264
1265 return Result;
1266}
#define CONTROLLER_COMMAND_WRITE_MOUSE
Definition: machpc.c:77
static VOID PS2ControllerWait(VOID)
Definition: machpc.c:1162
#define CONTROLLER_REGISTER_CONTROL
Definition: machpc.c:62

Referenced by DetectPS2Mouse().

◆ DetectPS2AuxPort()

static BOOLEAN DetectPS2AuxPort ( VOID  )
static

Definition at line 1180 of file machpc.c.

1181{
1182#if 1
1183 /* Current detection is too unreliable. Just do as if
1184 * the PS/2 aux port is always present
1185 */
1186 return TRUE;
1187#else
1188 ULONG Loops;
1189 UCHAR Status;
1190
1191 /* Put the value 0x5A in the output buffer using the
1192 * "WriteAuxiliary Device Output Buffer" command (0xD3).
1193 * Poll the Status Register for a while to see if the value really turns up
1194 * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1195 * to 1 in the Status Register, we assume this controller has an
1196 * Auxiliary Port (a.k.a. Mouse Port).
1197 */
1202
1203 /* 0x5A is a random dummy value */
1205 0x5A);
1206
1207 for (Loops = 0; Loops < 10; Loops++)
1208 {
1212 break;
1213 }
1214
1216
1218#endif
1219}
#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 1272 of file machpc.c.

1273{
1274 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1275 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1276 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
1277 ULONG Size;
1278
1279 if (DetectPS2AuxPort())
1280 {
1281 TRACE("Detected PS2 port\n");
1282
1283 PartialResourceList = FrLdrHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST), TAG_HW_RESOURCE_LIST);
1284 if (PartialResourceList == NULL)
1285 {
1286 ERR("Failed to allocate resource descriptor\n");
1287 return;
1288 }
1289
1290 /* Initialize resource descriptor */
1291 RtlZeroMemory(PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST));
1292 PartialResourceList->Version = 1;
1293 PartialResourceList->Revision = 1;
1294 PartialResourceList->Count = 1;
1295
1296 /* Set Interrupt */
1297 PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeInterrupt;
1299 PartialResourceList->PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1300 PartialResourceList->PartialDescriptors[0].u.Interrupt.Level = 12;
1301 PartialResourceList->PartialDescriptors[0].u.Interrupt.Vector = 12;
1302 PartialResourceList->PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF;
1303
1304 /* Create controller key */
1308 Input,
1309 0,
1310 0xFFFFFFFF,
1311 NULL,
1312 PartialResourceList,
1314 &ControllerKey);
1315
1316 if (DetectPS2AuxDevice())
1317 {
1318 TRACE("Detected PS2 mouse\n");
1319
1320 /* Initialize resource descriptor */
1321 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1323 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1324 if (PartialResourceList == NULL)
1325 {
1326 ERR("Failed to allocate resource descriptor\n");
1327 return;
1328 }
1329
1330 RtlZeroMemory(PartialResourceList, Size);
1331 PartialResourceList->Version = 1;
1332 PartialResourceList->Revision = 1;
1333 PartialResourceList->Count = 0;
1334
1335 /* Create peripheral key */
1336 FldrCreateComponentKey(ControllerKey,
1339 Input,
1340 0,
1341 0xFFFFFFFF,
1342 "MICROSOFT PS2 MOUSE",
1343 PartialResourceList,
1344 Size,
1345 &PeripheralKey);
1346 }
1347 }
1348}
static BOOLEAN DetectPS2AuxDevice(VOID)
Definition: machpc.c:1223
static BOOLEAN DetectPS2AuxPort(VOID)
Definition: machpc.c:1180
@ PointerController
Definition: arc.h:125
@ PointerPeripheral
Definition: arc.h:135

Referenced by DetectIsaBios().

◆ DetectSerialMouse()

static ULONG DetectSerialMouse ( PUCHAR  Port)
static

Definition at line 389 of file machpc.c.

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

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

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

Referenced by DetectIsaBios().

◆ GetSerialMouseDetectionBitmap()

static ULONG GetSerialMouseDetectionBitmap ( _In_opt_ PCSTR  Options)
static

Definition at line 726 of file machpc.c.

728{
729 PCSTR Option, c;
730 ULONG OptionLength, PortBitmap, i;
731
732 if (NtLdrGetOption(Options, "FASTDETECT"))
733 return (1 << MAX_COM_PORTS) - 1;
734
735 Option = NtLdrGetOptionEx(Options, "NOSERIALMICE=", &OptionLength);
736 if (!Option)
737 Option = NtLdrGetOptionEx(Options, "NOSERIALMICE:", &OptionLength);
738
739 if (!Option)
740 return 0;
741
742 /* Invalid port list */
743 if (OptionLength < (sizeof("NOSERIALMICE=COM9") - 1))
744 return (1 << MAX_COM_PORTS) - 1;
745
746 /* Move to the port list */
747 Option += sizeof("NOSERIALMICE=COM") - 1;
748 OptionLength -= sizeof("NOSERIALMICE=COM") - 1;
749
750 PortBitmap = 0;
751 c = Option;
752 for (i = 0; i < OptionLength; i += 2)
753 {
754 UCHAR PortNumber = *c - '0';
755
756 if (PortNumber > 0 && PortNumber <= 9)
757 PortBitmap |= 1 << (PortNumber - 1);
758
759 c += 2;
760 }
761
762 return PortBitmap;
763}
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 482 of file machpc.c.

483{
484 ULONG TimeOut;
485 ULONG i = 0;
486 char c;
487 char x;
488
489 WRITE_PORT_UCHAR(Port + 4, 0x09);
490
491 /* Wait 10 milliseconds for the mouse getting ready */
493
494 WRITE_PORT_UCHAR(Port + 4, 0x0b);
495
497
498 for (;;)
499 {
500 TimeOut = 200;
501 while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
502 {
504 --TimeOut;
505 if (TimeOut == 0)
506 {
507 return 0;
508 }
509 }
510
512 if (c == 0x08 || c == 0x28)
513 break;
514 }
515
516 Buffer[i++] = c;
517 x = c + 1;
518
519 for (;;)
520 {
521 TimeOut = 200;
522 while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
523 {
525 --TimeOut;
526 if (TimeOut == 0)
527 return 0;
528 }
530 Buffer[i++] = c;
531 if (c == x)
532 break;
533 if (i >= 256)
534 break;
535 }
536
537 return i;
538}

Referenced by DetectSerialPointerPeripheral().

◆ InitializeSerialPort()

static VOID InitializeSerialPort ( PUCHAR  Port,
UCHAR  LineControl 
)
static

Definition at line 375 of file machpc.c.

377{
378 WRITE_PORT_UCHAR(Port + 3, 0x80); /* set DLAB on */
379 WRITE_PORT_UCHAR(Port, 0x60); /* speed LO byte */
380 WRITE_PORT_UCHAR(Port + 1, 0); /* speed HI byte */
381 WRITE_PORT_UCHAR(Port + 3, LineControl);
382 WRITE_PORT_UCHAR(Port + 1, 0); /* set comm and DLAB to 0 */
383 WRITE_PORT_UCHAR(Port + 4, 0x09); /* DR int enable */
384 READ_PORT_UCHAR(Port + 5); /* clear error bits */
385}

Referenced by DetectSerialPointerPeripheral().

◆ MachInit()

VOID MachInit ( const char CmdLine)

Definition at line 1761 of file machpc.c.

1762{
1763 /* Setup vtbl */
1764 RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
1793
1795}
MACHVTBL MachVtbl
Definition: arcemul.c:21
BOOLEAN PcInitializeBootDevices(VOID)
Definition: hwdisk.c:473
VOID PcGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machpc.c:96
static UCHAR PcGetFloppyCount(VOID)
Definition: machpc.c:1664
PCONFIGURATION_COMPONENT_DATA PcHwDetect(_In_opt_ PCSTR Options)
Definition: machpc.c:1676
VOID PcHwIdle(VOID)
Definition: machpc.c:1706
VOID PcPrepareForReactOS(VOID)
Definition: machpc.c:1798
VOID PcBeep(VOID)
Definition: pcbeep.c:34
VOID PcConsPutChar(int Ch)
Definition: pccons.c:28
BOOLEAN PcConsKbHit(VOID)
Definition: pccons.c:69
int PcConsGetCh(void)
Definition: pccons.c:90
BOOLEAN PcDiskReadLogicalSectors(IN UCHAR DriveNumber, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
Definition: pcdisk.c:745
ULONG PcDiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: pcdisk.c:815
BOOLEAN PcDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: pcdisk.c:785
VOID HalpCalibrateStallExecution(VOID)
Definition: pchw.c:105
PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap(ULONG *MemoryMapSize)
Definition: pcmem.c:599
TIMEINFO * PcGetTime(VOID)
Definition: pcrtc.c:24
VOID PcVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
Definition: pcvideo.c:1010
BOOLEAN PcVideoIsPaletteFixed(VOID)
Definition: pcvideo.c:1114
VOID PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: pcvideo.c:1120
VOID PcVideoSync(VOID)
Definition: pcvideo.c:1138
VOID PcVideoGetFontsFromFirmware(PULONG RomFontPointers)
Definition: pcvideo.c:976
VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: pcvideo.c:946
VOID PcVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: pcvideo.c:1129
VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayModeName, BOOLEAN Init)
Definition: pcvideo.c:888
ULONG PcVideoGetBufferSize(VOID)
Definition: pcvideo.c:970
VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: pcvideo.c:1105
VOID PcVideoClearScreen(UCHAR Attr)
Definition: pcvideo.c:1089
VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: pcvideo.c:1048
VOID PcVideoHideShowTextCursor(BOOLEAN Show)
Definition: pcvideo.c:1035
VOID(* VideoGetPaletteColor)(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: machine.h:56
VOID(* GetExtendedBIOSData)(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machine.h:64
int(* ConsGetCh)(VOID)
Definition: machine.h:43
VOID(* PrepareForReactOS)(VOID)
Definition: machine.h:59
VOID(* VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: machine.h:55
BOOLEAN(* InitializeBootDevices)(VOID)
Definition: machine.h:76
VOID(* VideoCopyOffScreenBufferToVRAM)(PVOID Buffer)
Definition: machine.h:53
BOOLEAN(* ConsKbHit)(VOID)
Definition: machine.h:42
VOID(* VideoHideShowTextCursor)(BOOLEAN Show)
Definition: machine.h:51
TIMEINFO *(* GetTime)(VOID)
Definition: machine.h:72
UCHAR(* GetFloppyCount)(VOID)
Definition: machine.h:66
BOOLEAN(* DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry)
Definition: machine.h:68
BOOLEAN(* DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: machine.h:67
PFREELDR_MEMORY_DESCRIPTOR(* GetMemoryMap)(PULONG MaxMemoryMapSize)
Definition: machine.h:63
VOID(* VideoGetFontsFromFirmware)(PULONG RomFontPointers)
Definition: machine.h:49
VOID(* Beep)(VOID)
Definition: machine.h:58
VOID(* VideoSetTextCursorPosition)(UCHAR X, UCHAR Y)
Definition: machine.h:50
ULONG(* VideoGetBufferSize)(VOID)
Definition: machine.h:48
VOID(* VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: machine.h:52
ULONG(* DiskGetCacheableBlockCount)(UCHAR DriveNumber)
Definition: machine.h:69
VOID(* VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth)
Definition: machine.h:47
VOID(* VideoClearScreen)(UCHAR Attr)
Definition: machine.h:45
VOID(* HwIdle)(VOID)
Definition: machine.h:78
VOID(* VideoSync)(VOID)
Definition: machine.h:57
VIDEODISPLAYMODE(* VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init)
Definition: machine.h:46
BOOLEAN(* VideoIsPaletteFixed)(VOID)
Definition: machine.h:54
PCONFIGURATION_COMPONENT_DATA(* HwDetect)(_In_opt_ PCSTR Options)
Definition: machine.h:77
VOID(* ConsPutChar)(int Ch)
Definition: machine.h:41

◆ PcGetExtendedBIOSData()

VOID PcGetExtendedBIOSData ( PULONG  ExtendedBIOSDataArea,
PULONG  ExtendedBIOSDataSize 
)

Definition at line 96 of file machpc.c.

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

Referenced by MachInit().

◆ PcGetFloppyCount()

static UCHAR PcGetFloppyCount ( VOID  )
static

Definition at line 1664 of file machpc.c.

1665{
1666 UCHAR Data;
1667
1668 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
1669 Data = READ_PORT_UCHAR((PUCHAR)0x71);
1670
1671 return ((Data & 0xF0) ? 1 : 0) + ((Data & 0x0F) ? 1 : 0);
1672}

Referenced by MachInit().

◆ PcGetHarddiskConfigurationData()

static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData ( UCHAR  DriveNumber,
ULONG pSize 
)
static

Definition at line 120 of file machpc.c.

121{
122 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
124 GEOMETRY Geometry;
125 ULONG Size;
126
127 /* Initialize returned size */
128 *pSize = 0;
129
130 /* Set 'Configuration Data' value */
133 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
134 if (PartialResourceList == NULL)
135 {
136 ERR("Failed to allocate resource descriptor\n");
137 return NULL;
138 }
139
140 RtlZeroMemory(PartialResourceList, Size);
141 PartialResourceList->Version = 1;
142 PartialResourceList->Revision = 1;
143 PartialResourceList->Count = 1;
144 PartialResourceList->PartialDescriptors[0].Type =
146// PartialResourceList->PartialDescriptors[0].ShareDisposition =
147// PartialResourceList->PartialDescriptors[0].Flags =
148 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
150
151 /* Get pointer to geometry data */
152 DiskGeometry = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
153
154 /* Get the disk geometry */
155 if (PcDiskGetDriveGeometry(DriveNumber, &Geometry))
156 {
157 DiskGeometry->BytesPerSector = Geometry.BytesPerSector;
158 DiskGeometry->NumberOfCylinders = Geometry.Cylinders;
159 DiskGeometry->SectorsPerTrack = Geometry.SectorsPerTrack;
160 DiskGeometry->NumberOfHeads = Geometry.Heads;
161 }
162 else
163 {
164 TRACE("Reading disk geometry failed\n");
165 FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
166 return NULL;
167 }
168 TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
169 DriveNumber,
170 DiskGeometry->NumberOfCylinders,
171 DiskGeometry->NumberOfHeads,
172 DiskGeometry->SectorsPerTrack,
173 DiskGeometry->BytesPerSector);
174
175 /* Return configuration data */
176 *pSize = Size;
177 return PartialResourceList;
178}
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 701 of file machpc.c.

702{
703 static const ULONG PcIrq[MAX_COM_PORTS] = {4, 3, 4, 3};
704 PUSHORT BasePtr;
705
706 /*
707 * The BIOS data area 0x400 holds the address of the first valid COM port.
708 * Each COM port address is stored in a 2-byte field.
709 * Infos at: https://web.archive.org/web/20240119203029/http://www.bioscentral.com/misc/bda.htm
710 */
711 BasePtr = (PUSHORT)0x400;
712 *Irq = PcIrq[Index];
713
714 return (ULONG) *(BasePtr + Index);
715}
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by DetectIsaBios().

◆ PcHwDetect()

PCONFIGURATION_COMPONENT_DATA PcHwDetect ( _In_opt_ PCSTR  Options)

Definition at line 1676 of file machpc.c.

1678{
1680 ULONG BusNumber = 0;
1681
1682 TRACE("DetectHardware()\n");
1683
1684 /* Create the 'System' key */
1685 // TODO: Discover and set the other machine types
1686 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
1687
1690
1691 /* Detect buses */
1692 DetectPciBios(SystemKey, &BusNumber);
1693 DetectApmBios(SystemKey, &BusNumber);
1694 DetectPnpBios(SystemKey, &BusNumber);
1695 DetectIsaBios(Options, SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
1696 DetectAcpiBios(SystemKey, &BusNumber);
1697
1698 // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
1699 // CM_ROM_BLOCK data into the 'System' key's configuration data.
1700
1701 TRACE("DetectHardware() Done\n");
1702 return SystemKey;
1703}
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:239
static VOID DetectIsaBios(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA SystemKey, _Out_ ULONG *BusNumber)
Definition: machpc.c:1606
static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: machpc.c:120
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData
Definition: pchw.c:45
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160

Referenced by MachInit().

◆ PcHwIdle()

VOID PcHwIdle ( VOID  )

Definition at line 1706 of file machpc.c.

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

Referenced by MachInit().

◆ PcPrepareForReactOS()

VOID PcPrepareForReactOS ( VOID  )

Definition at line 1798 of file machpc.c.

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

Referenced by MachInit().

◆ PS2ControllerWait()

static VOID PS2ControllerWait ( VOID  )
static

Definition at line 1162 of file machpc.c.

1163{
1164 ULONG Timeout;
1165 UCHAR Status;
1166
1168 {
1171 return;
1172
1173 /* Sleep for one millisecond */
1175 }
1176}
#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().