ReactOS 0.4.16-dev-1946-g52006dd
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 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: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 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:116

Referenced by DetectDisplayController().

◆ ChainLoadBiosBootSectorCode()

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

Definition at line 1744 of file machpc.c.

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

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( HWDETECT  )

◆ DetectDisplayController()

static VOID DetectDisplayController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1569 of file machpc.c.

1570{
1572 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1573 USHORT VesaVersion;
1574
1575 /* FIXME: Set 'ComponentInformation' value */
1576
1577 VesaVersion = BiosIsVesaSupported();
1578 if (VesaVersion != 0)
1579 {
1580 TRACE("VESA version %c.%c\n",
1581 (VesaVersion >> 8) + '0',
1582 (VesaVersion & 0xFF) + '0');
1583 }
1584 else
1585 {
1586 TRACE("VESA not supported\n");
1587 }
1588
1589 if (VesaVersion >= 0x0200)
1590 Identifier = "VBE Display";
1591 else
1592 Identifier = "VGA Display";
1593
1598 0,
1599 0xFFFFFFFF,
1600 Identifier,
1601 NULL,
1602 0,
1603 &ControllerKey);
1604
1605 /* FIXME: Add display peripheral (monitor) data */
1606 if (VesaVersion != 0)
1607 {
1609 {
1610 TRACE("VESA/DDC supported!\n");
1611 if (BiosVesaReadEdid())
1612 {
1613 TRACE("EDID data read successfully!\n");
1614 }
1615 }
1616 }
1617}
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: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 */
205 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
206 if (PartialResourceList == NULL)
207 {
208 ERR("Failed to allocate resource descriptor\n");
209 return;
210 }
211
212 /* Initialize resource descriptor */
213 RtlZeroMemory(PartialResourceList, Size);
214 PartialResourceList->Version = 0;
215 PartialResourceList->Revision = 0;
216 PartialResourceList->Count = 1;
217
218 /* Set device specific data */
219 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
220 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
222 PartialDescriptor->Flags = 0;
223 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(DOCKING_STATE_INFORMATION);
224
225 DockingState = (PDOCKING_STATE_INFORMATION)&PartialResourceList->PartialDescriptors[1];
226 DockingState->ReturnCode = Result;
227 if (Result == 0)
228 {
229 DockInfo = (PPNP_DOCK_INFO)DiskReadBuffer;
230 DockingState->DockLocationID = DockInfo->DockLocationID;
231 DockingState->SerialNumber = DockInfo->SerialNumber;
232 DockingState->Capabilities = DockInfo->Capabilities;
233 TRACE("System docked\n");
234 TRACE("Location: 0x%08lx\n", DockInfo->DockLocationID);
235 TRACE("Serial: 0x%08lx\n", DockInfo->SerialNumber);
236 TRACE("Capabilities: 0x%04hx\n", DockInfo->Capabilities);
237 }
238
239 /* Create controller key */
243 0,
244 0,
245 0xFFFFFFFF,
246 "Docking State Information",
247 PartialResourceList,
248 Size,
249 &PeripheralKey);
250}
#define DiskReadBuffer
Definition: hardware.h:33
ULONG __cdecl PnpBiosGetDockStationInformation(UCHAR *DockingStationInfo)
PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: heap.c:533
if(dx< 0)
Definition: linetemp.h:194
struct _PNP_DOCK_INFO * PPNP_DOCK_INFO
struct _DOCKING_STATE_INFORMATION DOCKING_STATE_INFORMATION
struct _DOCKING_STATE_INFORMATION * PDOCKING_STATE_INFORMATION
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
#define CmResourceTypeDeviceSpecific
Definition: restypes.h:108
@ PeripheralClass
Definition: arc.h:104
@ DockingInformation
Definition: arc.h:151
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@430::@439 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@430 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
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 1621 of file machpc.c.

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

Referenced by PcHwDetect().

◆ DetectKeyboardController()

static VOID DetectKeyboardController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1110 of file machpc.c.

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

Referenced by DetectIsaBios().

◆ DetectKeyboardDevice()

BOOLEAN DetectKeyboardDevice ( VOID  )

Definition at line 976 of file machpc.c.

977{
979 UCHAR Scancode;
980 ULONG Loops;
982
983 /* Identify device */
985
986 /* Wait for reply */
987 for (Loops = 0; Loops < 100; Loops++)
988 {
992 break;
993 }
994
996 {
997 /* PC/XT keyboard or no keyboard */
998 Result = FALSE;
999 }
1000
1002 if (Scancode != 0xFA)
1003 {
1004 /* No ACK received */
1005 Result = FALSE;
1006 }
1007
1009
1012 {
1013 /* Found AT keyboard */
1014 return Result;
1015 }
1016
1018 if (Scancode != 0xAB)
1019 {
1020 /* No 0xAB received */
1021 Result = FALSE;
1022 }
1023
1025
1028 {
1029 /* No byte in buffer */
1030 Result = FALSE;
1031 }
1032
1034 if (Scancode != 0x41)
1035 {
1036 /* No 0x41 received */
1037 Result = FALSE;
1038 }
1039
1040 /* Found MF-II keyboard */
1041 return Result;
1042}
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 1045 of file machpc.c.

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

Referenced by DetectKeyboardController().

◆ DetectParallelPorts()

static VOID DetectParallelPorts ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 884 of file machpc.c.

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

Referenced by DetectIsaBios().

◆ DetectPnpBios()

static VOID DetectPnpBios ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
ULONG BusNumber 
)
static

Definition at line 254 of file machpc.c.

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

1239{
1240 UCHAR Scancode;
1241 UCHAR Status;
1242 ULONG Loops;
1244
1249
1250 /* Identify device */
1252
1253 /* Wait for reply */
1254 for (Loops = 0; Loops < 100; Loops++)
1255 {
1259 break;
1260 }
1261
1264 Result = FALSE;
1265
1267 if (Scancode != 0xFA)
1268 Result = FALSE;
1269
1271
1274 Result = FALSE;
1275
1277 if (Scancode != 0x00)
1278 Result = FALSE;
1279
1280 return Result;
1281}
#define CONTROLLER_COMMAND_WRITE_MOUSE
Definition: machpc.c:77
static VOID PS2ControllerWait(VOID)
Definition: machpc.c:1177
#define CONTROLLER_REGISTER_CONTROL
Definition: machpc.c:62

Referenced by DetectPS2Mouse().

◆ DetectPS2AuxPort()

static BOOLEAN DetectPS2AuxPort ( VOID  )
static

Definition at line 1195 of file machpc.c.

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

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

Referenced by DetectIsaBios().

◆ DetectSerialMouse()

static ULONG DetectSerialMouse ( PUCHAR  Port)
static

Definition at line 404 of file machpc.c.

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

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

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

Referenced by DetectIsaBios().

◆ GetSerialMouseDetectionBitmap()

static ULONG GetSerialMouseDetectionBitmap ( _In_opt_ PCSTR  Options)
static

Definition at line 741 of file machpc.c.

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

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

Referenced by DetectSerialPointerPeripheral().

◆ InitializeSerialPort()

static VOID InitializeSerialPort ( PUCHAR  Port,
UCHAR  LineControl 
)
static

Definition at line 390 of file machpc.c.

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

Referenced by DetectSerialPointerPeripheral().

◆ MachInit()

VOID MachInit ( const char CmdLine)

Definition at line 1776 of file machpc.c.

1777{
1778 /* Setup vtbl */
1779 RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
1808
1810}
MACHVTBL MachVtbl
Definition: arcemul.c:21
BOOLEAN PcInitializeBootDevices(VOID)
Definition: hwdisk.c:458
VOID PcGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machpc.c:104
static UCHAR PcGetFloppyCount(VOID)
Definition: machpc.c:1679
PCONFIGURATION_COMPONENT_DATA PcHwDetect(_In_opt_ PCSTR Options)
Definition: machpc.c:1691
VOID PcHwIdle(VOID)
Definition: machpc.c:1721
VOID PcPrepareForReactOS(VOID)
Definition: machpc.c:1813
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: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: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 104 of file machpc.c.

105{
106 REGS BiosRegs;
107
108 /* Get address and size of the extended BIOS data area */
109 BiosRegs.d.eax = 0xC100;
110 Int386(0x15, &BiosRegs, &BiosRegs);
111 if (INT386_SUCCESS(BiosRegs))
112 {
113 *ExtendedBIOSDataArea = BiosRegs.w.es << 4;
114 *ExtendedBIOSDataSize = 1024;
115 }
116 else
117 {
118 WARN("Int 15h AH=C1h call failed\n");
121 }
122}
#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 1679 of file machpc.c.

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

Referenced by MachInit().

◆ PcGetHarddiskConfigurationData()

static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData ( UCHAR  DriveNumber,
ULONG pSize 
)
static

Definition at line 128 of file machpc.c.

129{
130 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
132 GEOMETRY Geometry;
133 ULONG Size;
134
135 /* Initialize returned size */
136 *pSize = 0;
137
138 /* Set 'Configuration Data' value */
141 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
142 if (PartialResourceList == NULL)
143 {
144 ERR("Failed to allocate resource descriptor\n");
145 return NULL;
146 }
147
148 RtlZeroMemory(PartialResourceList, Size);
149 PartialResourceList->Version = 1;
150 PartialResourceList->Revision = 1;
151 PartialResourceList->Count = 1;
152 PartialResourceList->PartialDescriptors[0].Type =
154// PartialResourceList->PartialDescriptors[0].ShareDisposition =
155// PartialResourceList->PartialDescriptors[0].Flags =
156 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
158
159 /* Get pointer to geometry data */
160 DiskGeometry = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
161
162 /* Get the disk geometry */
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
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 716 of file machpc.c.

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

Referenced by DetectIsaBios().

◆ PcHwDetect()

PCONFIGURATION_COMPONENT_DATA PcHwDetect ( _In_opt_ PCSTR  Options)

Definition at line 1691 of file machpc.c.

1693{
1695 ULONG BusNumber = 0;
1696
1697 TRACE("DetectHardware()\n");
1698
1699 /* Create the 'System' key */
1700 // TODO: Discover and set the other machine types
1701 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
1702
1705
1706 /* Detect buses */
1707 DetectPciBios(SystemKey, &BusNumber);
1708 DetectApmBios(SystemKey, &BusNumber);
1709 DetectPnpBios(SystemKey, &BusNumber);
1710 DetectIsaBios(Options, SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
1711 DetectAcpiBios(SystemKey, &BusNumber);
1712
1713 // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
1714 // CM_ROM_BLOCK data into the 'System' key's configuration data.
1715
1716 TRACE("DetectHardware() Done\n");
1717 return SystemKey;
1718}
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:254
static VOID DetectIsaBios(_In_opt_ PCSTR Options, _Inout_ PCONFIGURATION_COMPONENT_DATA SystemKey, _Out_ ULONG *BusNumber)
Definition: machpc.c:1621
static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: machpc.c:128
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 1721 of file machpc.c.

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

Referenced by MachInit().

◆ PcPrepareForReactOS()

VOID PcPrepareForReactOS ( VOID  )

Definition at line 1813 of file machpc.c.

1814{
1815 /* On PC, prepare video and turn off the floppy motor */
1818}
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 1177 of file machpc.c.

1178{
1179 ULONG Timeout;
1180 UCHAR Status;
1181
1183 {
1186 return;
1187
1188 /* Sleep for one millisecond */
1190 }
1191}
#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().