ReactOS 0.4.15-dev-6669-g8227c5d
machpc.c File Reference
#include <freeldr.h>
#include <cportlib/cportlib.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)
 
ULONG PcGetSerialPort (ULONG Index, PULONG Irq)
 
VOID DetectSerialPorts (PCONFIGURATION_COMPONENT_DATA BusKey, GET_SERIAL_PORT MachGetSerialPort, 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 (PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
 
static UCHAR PcGetFloppyCount (VOID)
 
PCONFIGURATION_COMPONENT_DATA PcHwDetect (VOID)
 
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:83
#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL
Definition: machpc.c:78

Definition at line 86 of file machpc.c.

◆ CONTROLLER_COMMAND_GET_VERSION

#define CONTROLLER_COMMAND_GET_VERSION   0xA1

Definition at line 66 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_DISABLE

#define CONTROLLER_COMMAND_KEYBOARD_DISABLE   0xAD

Definition at line 72 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_ENABLE

#define CONTROLLER_COMMAND_KEYBOARD_ENABLE   0xAE

Definition at line 73 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_TEST

#define CONTROLLER_COMMAND_KEYBOARD_TEST   0xAB

Definition at line 71 of file machpc.c.

◆ CONTROLLER_COMMAND_MOUSE_DISABLE

#define CONTROLLER_COMMAND_MOUSE_DISABLE   0xA7

Definition at line 67 of file machpc.c.

◆ CONTROLLER_COMMAND_MOUSE_ENABLE

#define CONTROLLER_COMMAND_MOUSE_ENABLE   0xA8

Definition at line 68 of file machpc.c.

◆ CONTROLLER_COMMAND_READ_MODE

#define CONTROLLER_COMMAND_READ_MODE   0x20

Definition at line 64 of file machpc.c.

◆ CONTROLLER_COMMAND_SELF_TEST

#define CONTROLLER_COMMAND_SELF_TEST   0xAA

Definition at line 70 of file machpc.c.

◆ CONTROLLER_COMMAND_TEST_MOUSE

#define CONTROLLER_COMMAND_TEST_MOUSE   0xA9

Definition at line 69 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MODE

#define CONTROLLER_COMMAND_WRITE_MODE   0x60

Definition at line 65 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MOUSE

#define CONTROLLER_COMMAND_WRITE_MOUSE   0xD4

Definition at line 75 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER

#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER   0xD3

Definition at line 74 of file machpc.c.

◆ CONTROLLER_REGISTER_CONTROL

#define CONTROLLER_REGISTER_CONTROL   0x64

Definition at line 60 of file machpc.c.

◆ CONTROLLER_REGISTER_DATA

#define CONTROLLER_REGISTER_DATA   0x60

Definition at line 61 of file machpc.c.

◆ CONTROLLER_REGISTER_STATUS

#define CONTROLLER_REGISTER_STATUS   0x64

Definition at line 59 of file machpc.c.

◆ CONTROLLER_STATUS_COMMAND

#define CONTROLLER_STATUS_COMMAND   0x08

Definition at line 81 of file machpc.c.

◆ CONTROLLER_STATUS_GENERAL_TIMEOUT

#define CONTROLLER_STATUS_GENERAL_TIMEOUT   0x40

Definition at line 84 of file machpc.c.

◆ CONTROLLER_STATUS_INPUT_BUFFER_FULL

#define CONTROLLER_STATUS_INPUT_BUFFER_FULL   0x02

Definition at line 79 of file machpc.c.

◆ CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL

#define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL   0x20

Definition at line 83 of file machpc.c.

◆ CONTROLLER_STATUS_OUTPUT_BUFFER_FULL

#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL   0x01

Definition at line 78 of file machpc.c.

◆ CONTROLLER_STATUS_PARITY_ERROR

#define CONTROLLER_STATUS_PARITY_ERROR   0x80

Definition at line 85 of file machpc.c.

◆ CONTROLLER_STATUS_SELF_TEST

#define CONTROLLER_STATUS_SELF_TEST   0x04

Definition at line 80 of file machpc.c.

◆ CONTROLLER_STATUS_UNLOCKED

#define CONTROLLER_STATUS_UNLOCKED   0x10

Definition at line 82 of file machpc.c.

◆ CONTROLLER_TIMEOUT

#define CONTROLLER_TIMEOUT   250

Definition at line 90 of file machpc.c.

◆ INPORT_MODE_BASE

#define INPORT_MODE_BASE   0x10

Definition at line 47 of file machpc.c.

◆ INPORT_REG_MODE

#define INPORT_REG_MODE   0x07

Definition at line 45 of file machpc.c.

◆ INPORT_REGISTER_CONTROL

#define INPORT_REGISTER_CONTROL   0x00

Definition at line 41 of file machpc.c.

◆ INPORT_REGISTER_DATA

#define INPORT_REGISTER_DATA   0x01

Definition at line 42 of file machpc.c.

◆ INPORT_REGISTER_SIGNATURE

#define INPORT_REGISTER_SIGNATURE   0x02

Definition at line 43 of file machpc.c.

◆ INPORT_RESET

#define INPORT_RESET   0x80

Definition at line 46 of file machpc.c.

◆ INPORT_SIGNATURE

#define INPORT_SIGNATURE   0xDE

Definition at line 49 of file machpc.c.

◆ INPORT_TEST_IRQ

#define INPORT_TEST_IRQ   0x16

Definition at line 48 of file machpc.c.

◆ MAX_COM_PORTS

#define MAX_COM_PORTS   4

Definition at line 27 of file machpc.c.

◆ MAX_LPT_PORTS

#define MAX_LPT_PORTS   3

Definition at line 28 of file machpc.c.

◆ MOUSE_TYPE_LOGITECH

#define MOUSE_TYPE_LOGITECH   2

Definition at line 35 of file machpc.c.

◆ MOUSE_TYPE_MICROSOFT

#define MOUSE_TYPE_MICROSOFT   1

Definition at line 33 of file machpc.c.

◆ MOUSE_TYPE_MOUSESYSTEMS

#define MOUSE_TYPE_MOUSESYSTEMS   4

Definition at line 39 of file machpc.c.

◆ MOUSE_TYPE_NONE

#define MOUSE_TYPE_NONE   0

Definition at line 31 of file machpc.c.

◆ MOUSE_TYPE_WHEELZ

#define MOUSE_TYPE_WHEELZ   3

Definition at line 37 of file machpc.c.

◆ PIC1_CONTROL_PORT

#define PIC1_CONTROL_PORT   0x20

Definition at line 51 of file machpc.c.

◆ PIC1_DATA_PORT

#define PIC1_DATA_PORT   0x21

Definition at line 52 of file machpc.c.

◆ PIC2_CONTROL_PORT

#define PIC2_CONTROL_PORT   0xA0

Definition at line 53 of file machpc.c.

◆ PIC2_DATA_PORT

#define PIC2_DATA_PORT   0xA1

Definition at line 54 of file machpc.c.

Function Documentation

◆ BiosIsVesaDdcSupported()

BOOLEAN BiosIsVesaDdcSupported ( VOID  )

Definition at line 242 of file pcvesa.c.

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

Referenced by DetectDisplayController().

◆ BiosIsVesaSupported()

USHORT BiosIsVesaSupported ( VOID  )

Definition at line 160 of file pcvesa.c.

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

1686{
1687 REGS Regs;
1688
1689 RtlZeroMemory(&Regs, sizeof(Regs));
1690
1691 /* Set the boot drive and the boot partition */
1692 Regs.b.dl = (UCHAR)(BootDrive ? BootDrive : FrldrBootDrive);
1693 Regs.b.dh = (UCHAR)(BootPartition ? BootPartition : FrldrBootPartition);
1694
1695 /*
1696 * Don't stop the floppy drive motor when we are just booting a bootsector,
1697 * a drive, or a partition. If we were to stop the floppy motor, the BIOS
1698 * wouldn't be informed and if the next read is to a floppy then the BIOS
1699 * will still think the motor is on and this will result in a read error.
1700 */
1701 // DiskStopFloppyMotor();
1702
1703 Relocator16Boot(&Regs,
1704 /* Stack segment:pointer */
1705 0x0000, 0x7C00,
1706 /* Code segment:pointer */
1707 0x0000, 0x7C00);
1708}
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 1512 of file machpc.c.

1513{
1515 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1516 USHORT VesaVersion;
1517
1518 /* FIXME: Set 'ComponentInformation' value */
1519
1520 VesaVersion = BiosIsVesaSupported();
1521 if (VesaVersion != 0)
1522 {
1523 TRACE("VESA version %c.%c\n",
1524 (VesaVersion >> 8) + '0',
1525 (VesaVersion & 0xFF) + '0');
1526 }
1527 else
1528 {
1529 TRACE("VESA not supported\n");
1530 }
1531
1532 if (VesaVersion >= 0x0200)
1533 Identifier = "VBE Display";
1534 else
1535 Identifier = "VGA Display";
1536
1541 0,
1542 0xFFFFFFFF,
1543 Identifier,
1544 NULL,
1545 0,
1546 &ControllerKey);
1547
1548 /* FIXME: Add display peripheral (monitor) data */
1549 if (VesaVersion != 0)
1550 {
1552 {
1553 TRACE("VESA/DDC supported!\n");
1554 if (BiosVesaReadEdid())
1555 {
1556 TRACE("EDID data read successfully!\n");
1557 }
1558 }
1559 }
1560}
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 196 of file machpc.c.

198{
199 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
200 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
201 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
202 PDOCKING_STATE_INFORMATION DockingState;
204
206
207 /* Build full device descriptor */
210 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
211 if (PartialResourceList == NULL)
212 {
213 ERR("Failed to allocate resource descriptor\n");
214 return;
215 }
216
217 /* Initialize resource descriptor */
218 RtlZeroMemory(PartialResourceList, Size);
219 PartialResourceList->Version = 0;
220 PartialResourceList->Revision = 0;
221 PartialResourceList->Count = 1;
222
223 /* Set device specific data */
224 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
225 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
227 PartialDescriptor->Flags = 0;
228 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(DOCKING_STATE_INFORMATION);
229
230 DockingState = (PDOCKING_STATE_INFORMATION)&PartialResourceList->PartialDescriptors[1];
231 DockingState->ReturnCode = Result;
232 if (Result == 0)
233 {
234 /* FIXME: Add more device specific data */
235 ERR("FIXME: System docked\n");
236 }
237
238 /* Create controller key */
242 0,
243 0,
244 0xFFFFFFFF,
245 "Docking State Information",
246 PartialResourceList,
247 Size,
248 &PeripheralKey);
249}
#define DiskReadBuffer
Definition: hardware.h:33
ULONG __cdecl PnpBiosGetDockStationInformation(UCHAR *DockingStationInfo)
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:174
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
if(dx< 0)
Definition: linetemp.h:194
struct _DOCKING_STATE_INFORMATION DOCKING_STATE_INFORMATION
struct _DOCKING_STATE_INFORMATION * PDOCKING_STATE_INFORMATION
@ PeripheralClass
Definition: arc.h:95
@ DockingInformation
Definition: arc.h:142
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382::@391 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382 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 ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
ULONG BusNumber 
)
static

Definition at line 1564 of file machpc.c.

1565{
1566 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1568 ULONG Size;
1569
1570 /* Set 'Configuration Data' value */
1571 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1573 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1574 if (PartialResourceList == NULL)
1575 {
1576 ERR("Failed to allocate resource descriptor\n");
1577 return;
1578 }
1579
1580 /* Initialize resource descriptor */
1581 RtlZeroMemory(PartialResourceList, Size);
1582 PartialResourceList->Version = 1;
1583 PartialResourceList->Revision = 1;
1584 PartialResourceList->Count = 0;
1585
1586 /* Create new bus key */
1587 FldrCreateComponentKey(SystemKey,
1590 0,
1591 0,
1592 0xFFFFFFFF,
1593 "ISA",
1594 PartialResourceList,
1595 Size,
1596 &BusKey);
1597
1598 /* Increment bus number */
1599 (*BusNumber)++;
1600
1601 /* Detect ISA/BIOS devices */
1602 DetectBiosDisks(SystemKey, BusKey);
1604 DetectParallelPorts(BusKey);
1606 DetectPS2Mouse(BusKey);
1607#if defined(_M_IX86)
1608 DetectBusMouse(BusKey);
1609#endif
1611
1612 /* FIXME: Detect more ISA devices */
1613}
ULONG PcGetSerialPort(ULONG Index, PULONG Irq)
Definition: machpc.c:714
#define MAX_COM_PORTS
Definition: machpc.c:27
static VOID DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1053
VOID DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey, GET_SERIAL_PORT MachGetSerialPort, ULONG Count)
Definition: machpc.c:731
static VOID DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1230
static VOID DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:827
static VOID DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1512
VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pchw.c:344
@ AdapterClass
Definition: arc.h:93
@ MultiFunctionAdapter
Definition: arc.h:116

Referenced by PcHwDetect().

◆ DetectKeyboardController()

static VOID DetectKeyboardController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1053 of file machpc.c.

1054{
1055 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1056 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
1057 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1058 ULONG Size;
1059
1060 /* Set 'Configuration Data' value */
1061 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
1063 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1064 if (PartialResourceList == NULL)
1065 {
1066 ERR("Failed to allocate resource descriptor\n");
1067 return;
1068 }
1069
1070 /* Initialize resource descriptor */
1071 RtlZeroMemory(PartialResourceList, Size);
1072 PartialResourceList->Version = 1;
1073 PartialResourceList->Revision = 1;
1074 PartialResourceList->Count = 3;
1075
1076 /* Set Interrupt */
1077 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1078 PartialDescriptor->Type = CmResourceTypeInterrupt;
1079 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1080 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1081 PartialDescriptor->u.Interrupt.Level = 1;
1082 PartialDescriptor->u.Interrupt.Vector = 1;
1083 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
1084
1085 /* Set IO Port 0x60 */
1086 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
1087 PartialDescriptor->Type = CmResourceTypePort;
1089 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1090 PartialDescriptor->u.Port.Start.LowPart = 0x60;
1091 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1092 PartialDescriptor->u.Port.Length = 1;
1093
1094 /* Set IO Port 0x64 */
1095 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
1096 PartialDescriptor->Type = CmResourceTypePort;
1098 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1099 PartialDescriptor->u.Port.Start.LowPart = 0x64;
1100 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1101 PartialDescriptor->u.Port.Length = 1;
1102
1103 /* Create controller key */
1107 Input | ConsoleIn,
1108 0,
1109 0xFFFFFFFF,
1110 NULL,
1111 PartialResourceList,
1112 Size,
1113 &ControllerKey);
1114
1115 DetectKeyboardPeripheral(ControllerKey);
1116}
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
static VOID DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: machpc.c:988
#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::@382::@384 Port
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382::@385 Interrupt
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241

Referenced by DetectIsaBios().

◆ DetectKeyboardDevice()

BOOLEAN DetectKeyboardDevice ( VOID  )

Definition at line 919 of file machpc.c.

920{
922 UCHAR Scancode;
923 ULONG Loops;
925
926 /* Identify device */
928
929 /* Wait for reply */
930 for (Loops = 0; Loops < 100; Loops++)
931 {
935 break;
936 }
937
939 {
940 /* PC/XT keyboard or no keyboard */
941 Result = FALSE;
942 }
943
945 if (Scancode != 0xFA)
946 {
947 /* No ACK received */
948 Result = FALSE;
949 }
950
952
955 {
956 /* Found AT keyboard */
957 return Result;
958 }
959
961 if (Scancode != 0xAB)
962 {
963 /* No 0xAB received */
964 Result = FALSE;
965 }
966
968
971 {
972 /* No byte in buffer */
973 Result = FALSE;
974 }
975
977 if (Scancode != 0x41)
978 {
979 /* No 0x41 received */
980 Result = FALSE;
981 }
982
983 /* Found MF-II keyboard */
984 return Result;
985}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
Status
Definition: gdiplustypes.h:25
#define CONTROLLER_REGISTER_STATUS
Definition: machpc.c:59
#define CONTROLLER_REGISTER_DATA
Definition: machpc.c:61
#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 988 of file machpc.c.

989{
990 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
991 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
992 PCM_KEYBOARD_DEVICE_DATA KeyboardData;
993 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
994 ULONG Size;
995 REGS Regs;
996
997 /* HACK: don't call DetectKeyboardDevice() as it fails in Qemu 0.8.2
998 if (DetectKeyboardDevice()) */
999 {
1000 /* Set 'Configuration Data' value */
1001 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
1003 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1004 if (PartialResourceList == NULL)
1005 {
1006 ERR("Failed to allocate resource descriptor\n");
1007 return;
1008 }
1009
1010 /* Initialize resource descriptor */
1011 RtlZeroMemory(PartialResourceList, Size);
1012 PartialResourceList->Version = 1;
1013 PartialResourceList->Revision = 1;
1014 PartialResourceList->Count = 1;
1015
1016 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1017 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
1018 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1019 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_KEYBOARD_DEVICE_DATA);
1020
1021 /* Int 16h AH=02h
1022 * KEYBOARD - GET SHIFT FLAGS
1023 *
1024 * Return:
1025 * AL - shift flags
1026 */
1027 Regs.b.ah = 0x02;
1028 Int386(0x16, &Regs, &Regs);
1029
1030 KeyboardData = (PCM_KEYBOARD_DEVICE_DATA)(PartialDescriptor + 1);
1031 KeyboardData->Version = 1;
1032 KeyboardData->Revision = 1;
1033 KeyboardData->Type = 4;
1034 KeyboardData->Subtype = 0;
1035 KeyboardData->KeyboardFlags = Regs.b.al;
1036
1037 /* Create controller key */
1038 FldrCreateComponentKey(ControllerKey,
1041 Input | ConsoleIn,
1042 0,
1043 0xFFFFFFFF,
1044 "PCAT_ENHANCED",
1045 PartialResourceList,
1046 Size,
1047 &PeripheralKey);
1048 }
1049}
@ 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 827 of file machpc.c.

828{
829 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
830 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
831 ULONG Irq[MAX_LPT_PORTS] = {7, 5, (ULONG) - 1};
832 CHAR Identifier[80];
833 PCONFIGURATION_COMPONENT_DATA ControllerKey;
834 PUSHORT BasePtr;
835 ULONG Base;
836 ULONG ControllerNumber = 0;
837 ULONG i;
838 ULONG Size;
839
840 TRACE("DetectParallelPorts() called\n");
841
842 /*
843 * The BIOS data area 0x408 holds the address of the first valid LPT port.
844 * Each LPT port address is stored in a 2-byte field.
845 * Infos at: http://www.bioscentral.com/misc/bda.htm
846 */
847 BasePtr = (PUSHORT)0x408;
848
849 for (i = 0; i < MAX_LPT_PORTS; i++, BasePtr++)
850 {
851 Base = (ULONG) * BasePtr;
852 if (Base == 0)
853 continue;
854
855 TRACE("Parallel port %u: %x\n", ControllerNumber, Base);
856
857 /* Set 'Identifier' value */
858 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "PARALLEL%ld", i + 1);
859
860 /* Build full device descriptor */
862 if (Irq[i] != (ULONG) - 1)
864
865 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
866 if (PartialResourceList == NULL)
867 {
868 ERR("Failed to allocate resource descriptor! Ignoring remaining parallel ports. (i = %lu)\n", i);
869 break;
870 }
871
872 /* Initialize resource descriptor */
873 RtlZeroMemory(PartialResourceList, Size);
874 PartialResourceList->Version = 1;
875 PartialResourceList->Revision = 1;
876 PartialResourceList->Count = (Irq[i] != (ULONG) - 1) ? 2 : 1;
877
878 /* Set IO Port */
879 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
880 PartialDescriptor->Type = CmResourceTypePort;
882 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
883 PartialDescriptor->u.Port.Start.LowPart = Base;
884 PartialDescriptor->u.Port.Start.HighPart = 0x0;
885 PartialDescriptor->u.Port.Length = 3;
886
887 /* Set Interrupt */
888 if (Irq[i] != (ULONG) - 1)
889 {
890 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
891 PartialDescriptor->Type = CmResourceTypeInterrupt;
893 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
894 PartialDescriptor->u.Interrupt.Level = Irq[i];
895 PartialDescriptor->u.Interrupt.Vector = Irq[i];
896 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
897 }
898
899 /* Create controller key */
903 Output,
904 ControllerNumber,
905 0xFFFFFFFF,
907 PartialResourceList,
908 Size,
909 &ControllerKey);
910
911 ControllerNumber++;
912 }
913
914 TRACE("DetectParallelPorts() done\n");
915}
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:28
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2439
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
@ ParallelController
Definition: arc.h:124
uint16_t * PUSHORT
Definition: typedefs.h:56
char CHAR
Definition: xmlstorage.h:175

Referenced by DetectIsaBios().

◆ DetectPnpBios()

static VOID DetectPnpBios ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
ULONG BusNumber 
)
static

Definition at line 253 of file machpc.c.

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

1182{
1183 UCHAR Scancode;
1184 UCHAR Status;
1185 ULONG Loops;
1187
1192
1193 /* Identify device */
1195
1196 /* Wait for reply */
1197 for (Loops = 0; Loops < 100; Loops++)
1198 {
1202 break;
1203 }
1204
1207 Result = FALSE;
1208
1210 if (Scancode != 0xFA)
1211 Result = FALSE;
1212
1214
1217 Result = FALSE;
1218
1220 if (Scancode != 0x00)
1221 Result = FALSE;
1222
1223 return Result;
1224}
#define CONTROLLER_COMMAND_WRITE_MOUSE
Definition: machpc.c:75
static VOID PS2ControllerWait(VOID)
Definition: machpc.c:1120
#define CONTROLLER_REGISTER_CONTROL
Definition: machpc.c:60

Referenced by DetectPS2Mouse().

◆ DetectPS2AuxPort()

static BOOLEAN DetectPS2AuxPort ( VOID  )
static

Definition at line 1138 of file machpc.c.

1139{
1140#if 1
1141 /* Current detection is too unreliable. Just do as if
1142 * the PS/2 aux port is always present
1143 */
1144 return TRUE;
1145#else
1146 ULONG Loops;
1147 UCHAR Status;
1148
1149 /* Put the value 0x5A in the output buffer using the
1150 * "WriteAuxiliary Device Output Buffer" command (0xD3).
1151 * Poll the Status Register for a while to see if the value really turns up
1152 * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1153 * to 1 in the Status Register, we assume this controller has an
1154 * Auxiliary Port (a.k.a. Mouse Port).
1155 */
1160
1161 /* 0x5A is a random dummy value */
1163 0x5A);
1164
1165 for (Loops = 0; Loops < 10; Loops++)
1166 {
1170 break;
1171 }
1172
1174
1176#endif
1177}
#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER
Definition: machpc.c:74

Referenced by DetectPS2Mouse().

◆ DetectPS2Mouse()

static VOID DetectPS2Mouse ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1230 of file machpc.c.

1231{
1232 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1233 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1234 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
1235 ULONG Size;
1236
1237 if (DetectPS2AuxPort())
1238 {
1239 TRACE("Detected PS2 port\n");
1240
1241 PartialResourceList = FrLdrHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST), TAG_HW_RESOURCE_LIST);
1242 if (PartialResourceList == NULL)
1243 {
1244 ERR("Failed to allocate resource descriptor\n");
1245 return;
1246 }
1247
1248 /* Initialize resource descriptor */
1249 RtlZeroMemory(PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST));
1250 PartialResourceList->Version = 1;
1251 PartialResourceList->Revision = 1;
1252 PartialResourceList->Count = 1;
1253
1254 /* Set Interrupt */
1255 PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeInterrupt;
1257 PartialResourceList->PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1258 PartialResourceList->PartialDescriptors[0].u.Interrupt.Level = 12;
1259 PartialResourceList->PartialDescriptors[0].u.Interrupt.Vector = 12;
1260 PartialResourceList->PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF;
1261
1262 /* Create controller key */
1266 Input,
1267 0,
1268 0xFFFFFFFF,
1269 NULL,
1270 PartialResourceList,
1272 &ControllerKey);
1273
1274 if (DetectPS2AuxDevice())
1275 {
1276 TRACE("Detected PS2 mouse\n");
1277
1278 /* Initialize resource descriptor */
1279 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1281 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1282 if (PartialResourceList == NULL)
1283 {
1284 ERR("Failed to allocate resource descriptor\n");
1285 return;
1286 }
1287
1288 RtlZeroMemory(PartialResourceList, Size);
1289 PartialResourceList->Version = 1;
1290 PartialResourceList->Revision = 1;
1291 PartialResourceList->Count = 0;
1292
1293 /* Create peripheral key */
1294 FldrCreateComponentKey(ControllerKey,
1297 Input,
1298 0,
1299 0xFFFFFFFF,
1300 "MICROSOFT PS2 MOUSE",
1301 PartialResourceList,
1302 Size,
1303 &PeripheralKey);
1304 }
1305 }
1306}
static BOOLEAN DetectPS2AuxDevice(VOID)
Definition: machpc.c:1181
static BOOLEAN DetectPS2AuxPort(VOID)
Definition: machpc.c:1138
@ PointerController
Definition: arc.h:125
@ PointerPeripheral
Definition: arc.h:135

Referenced by DetectIsaBios().

◆ DetectSerialMouse()

static ULONG DetectSerialMouse ( PUCHAR  Port)
static

Definition at line 403 of file machpc.c.

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

Referenced by DetectSerialPointerPeripheral().

◆ DetectSerialPointerPeripheral()

static VOID DetectSerialPointerPeripheral ( PCONFIGURATION_COMPONENT_DATA  ControllerKey,
PUCHAR  Base 
)
static

Definition at line 556 of file machpc.c.

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

Referenced by DetectSerialPorts().

◆ DetectSerialPorts()

VOID DetectSerialPorts ( PCONFIGURATION_COMPONENT_DATA  BusKey,
GET_SERIAL_PORT  MachGetSerialPort,
ULONG  Count 
)

Definition at line 731 of file machpc.c.

732{
733 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
734 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
735 PCM_SERIAL_DEVICE_DATA SerialDeviceData;
736 ULONG Irq;
737 ULONG Base;
738 CHAR Identifier[80];
739 ULONG ControllerNumber = 0;
740 PCONFIGURATION_COMPONENT_DATA ControllerKey;
741 ULONG i;
742 ULONG Size;
743
744 TRACE("DetectSerialPorts()\n");
745
746 for (i = 0; i < Count; i++)
747 {
748 Base = MachGetSerialPort(i, &Irq);
749 if ((Base == 0) || !CpDoesPortExist(UlongToPtr(Base)))
750 continue;
751
752 TRACE("Found COM%u port at 0x%x\n", i + 1, Base);
753
754 /* Set 'Identifier' value */
755 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "COM%ld", i + 1);
756
757 /* Build full device descriptor */
760 sizeof(CM_SERIAL_DEVICE_DATA);
761 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
762 if (PartialResourceList == NULL)
763 {
764 ERR("Failed to allocate resource descriptor! Ignoring remaining serial ports. (i = %lu, Count = %lu)\n",
765 i, Count);
766 break;
767 }
768
769 /* Initialize resource descriptor */
770 RtlZeroMemory(PartialResourceList, Size);
771 PartialResourceList->Version = 1;
772 PartialResourceList->Revision = 1;
773 PartialResourceList->Count = 3;
774
775 /* Set IO Port */
776 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
777 PartialDescriptor->Type = CmResourceTypePort;
779 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
780 PartialDescriptor->u.Port.Start.LowPart = Base;
781 PartialDescriptor->u.Port.Start.HighPart = 0x0;
782 PartialDescriptor->u.Port.Length = 8;
783
784 /* Set Interrupt */
785 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
786 PartialDescriptor->Type = CmResourceTypeInterrupt;
788 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
789 PartialDescriptor->u.Interrupt.Level = Irq;
790 PartialDescriptor->u.Interrupt.Vector = Irq;
791 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
792
793 /* Set serial data (device specific) */
794 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
795 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
797 PartialDescriptor->Flags = 0;
798 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_SERIAL_DEVICE_DATA);
799
800 SerialDeviceData =
801 (PCM_SERIAL_DEVICE_DATA)&PartialResourceList->PartialDescriptors[3];
802 SerialDeviceData->BaudClock = 1843200; /* UART Clock frequency (Hertz) */
803
804 /* Create controller key */
809 ControllerNumber,
810 0xFFFFFFFF,
812 PartialResourceList,
813 Size,
814 &ControllerKey);
815
817 {
818 /* Detect serial mouse */
820 }
821
822 ControllerNumber++;
823 }
824}
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 VOID DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey, PUCHAR Base)
Definition: machpc.c:556
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().

◆ GetSerialMousePnpId()

static ULONG GetSerialMousePnpId ( PUCHAR  Port,
char Buffer 
)
static

Definition at line 496 of file machpc.c.

497{
498 ULONG TimeOut;
499 ULONG i = 0;
500 char c;
501 char x;
502
503 WRITE_PORT_UCHAR(Port + 4, 0x09);
504
505 /* Wait 10 milliseconds for the mouse getting ready */
507
508 WRITE_PORT_UCHAR(Port + 4, 0x0b);
509
511
512 for (;;)
513 {
514 TimeOut = 200;
515 while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
516 {
518 --TimeOut;
519 if (TimeOut == 0)
520 {
521 return 0;
522 }
523 }
524
526 if (c == 0x08 || c == 0x28)
527 break;
528 }
529
530 Buffer[i++] = c;
531 x = c + 1;
532
533 for (;;)
534 {
535 TimeOut = 200;
536 while (((READ_PORT_UCHAR(Port + 5) & 1) == 0) && (TimeOut > 0))
537 {
539 --TimeOut;
540 if (TimeOut == 0)
541 return 0;
542 }
544 Buffer[i++] = c;
545 if (c == x)
546 break;
547 if (i >= 256)
548 break;
549 }
550
551 return i;
552}
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80

Referenced by DetectSerialPointerPeripheral().

◆ InitializeSerialPort()

static VOID InitializeSerialPort ( PUCHAR  Port,
UCHAR  LineControl 
)
static

Definition at line 389 of file machpc.c.

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

Referenced by DetectSerialPointerPeripheral().

◆ MachInit()

VOID MachInit ( const char CmdLine)

Definition at line 1715 of file machpc.c.

1716{
1717 /* Setup vtbl */
1718 RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
1747
1749}
MACHVTBL MachVtbl
Definition: arcemul.c:21
BOOLEAN PcInitializeBootDevices(VOID)
Definition: hwdisk.c:470
VOID PcGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machpc.c:94
PCONFIGURATION_COMPONENT_DATA PcHwDetect(VOID)
Definition: machpc.c:1631
static UCHAR PcGetFloppyCount(VOID)
Definition: machpc.c:1619
VOID PcHwIdle(VOID)
Definition: machpc.c:1660
VOID PcPrepareForReactOS(VOID)
Definition: machpc.c:1752
VOID PcBeep(VOID)
Definition: pcbeep.c:34
VOID PcConsPutChar(int Ch)
Definition: pccons.c:28
BOOLEAN PcConsKbHit(VOID)
Definition: pccons.c:69
int PcConsGetCh(void)
Definition: pccons.c:90
BOOLEAN PcDiskReadLogicalSectors(IN UCHAR DriveNumber, IN ULONGLONG SectorNumber, IN ULONG SectorCount, OUT PVOID Buffer)
Definition: pcdisk.c:758
ULONG PcDiskGetCacheableBlockCount(UCHAR DriveNumber)
Definition: pcdisk.c:827
BOOLEAN PcDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: pcdisk.c:798
VOID HalpCalibrateStallExecution(VOID)
Definition: pchw.c:105
PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap(ULONG *MemoryMapSize)
Definition: pcmem.c:599
TIMEINFO * PcGetTime(VOID)
Definition: pcrtc.c:24
VOID PcVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
Definition: pcvideo.c:1010
BOOLEAN PcVideoIsPaletteFixed(VOID)
Definition: pcvideo.c:1114
VOID PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: pcvideo.c:1120
VOID PcVideoSync(VOID)
Definition: pcvideo.c:1138
VOID PcVideoGetFontsFromFirmware(PULONG RomFontPointers)
Definition: pcvideo.c:976
VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: pcvideo.c:946
VOID PcVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: pcvideo.c:1129
VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayModeName, BOOLEAN Init)
Definition: pcvideo.c:888
ULONG PcVideoGetBufferSize(VOID)
Definition: pcvideo.c:970
VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: pcvideo.c:1105
VOID PcVideoClearScreen(UCHAR Attr)
Definition: pcvideo.c:1089
VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: pcvideo.c:1048
VOID PcVideoHideShowTextCursor(BOOLEAN Show)
Definition: pcvideo.c:1035
VOID(* VideoGetPaletteColor)(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: machine.h:56
VOID(* GetExtendedBIOSData)(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machine.h:64
int(* ConsGetCh)(VOID)
Definition: machine.h:43
VOID(* PrepareForReactOS)(VOID)
Definition: machine.h:59
VOID(* VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: machine.h:55
BOOLEAN(* InitializeBootDevices)(VOID)
Definition: machine.h:76
VOID(* VideoCopyOffScreenBufferToVRAM)(PVOID Buffer)
Definition: machine.h:53
BOOLEAN(* ConsKbHit)(VOID)
Definition: machine.h:42
VOID(* VideoHideShowTextCursor)(BOOLEAN Show)
Definition: machine.h:51
TIMEINFO *(* GetTime)(VOID)
Definition: machine.h:72
UCHAR(* GetFloppyCount)(VOID)
Definition: machine.h:66
BOOLEAN(* DiskGetDriveGeometry)(UCHAR DriveNumber, PGEOMETRY DriveGeometry)
Definition: machine.h:68
BOOLEAN(* DiskReadLogicalSectors)(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
Definition: machine.h:67
PCONFIGURATION_COMPONENT_DATA(* HwDetect)(VOID)
Definition: machine.h:77
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
VOID(* ConsPutChar)(int Ch)
Definition: machine.h:41

◆ PcGetExtendedBIOSData()

VOID PcGetExtendedBIOSData ( PULONG  ExtendedBIOSDataArea,
PULONG  ExtendedBIOSDataSize 
)

Definition at line 94 of file machpc.c.

95{
96 REGS BiosRegs;
97
98 /* Get address and size of the extended BIOS data area */
99 BiosRegs.d.eax = 0xC100;
100 Int386(0x15, &BiosRegs, &BiosRegs);
101 if (INT386_SUCCESS(BiosRegs))
102 {
103 *ExtendedBIOSDataArea = BiosRegs.w.es << 4;
104 *ExtendedBIOSDataSize = 1024;
105 }
106 else
107 {
108 WARN("Int 15h AH=C1h call failed\n");
111 }
112}
#define ExtendedBIOSDataArea
Definition: winldr.c:420
#define ExtendedBIOSDataSize
Definition: winldr.c:421
#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 1619 of file machpc.c.

1620{
1621 UCHAR Data;
1622
1623 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
1624 Data = READ_PORT_UCHAR((PUCHAR)0x71);
1625
1626 return ((Data & 0xF0) ? 1 : 0) + ((Data & 0x0F) ? 1 : 0);
1627}

Referenced by MachInit().

◆ PcGetHarddiskConfigurationData()

static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData ( UCHAR  DriveNumber,
ULONG pSize 
)
static

Definition at line 118 of file machpc.c.

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

Referenced by PcHwDetect().

◆ PcGetSerialPort()

ULONG PcGetSerialPort ( ULONG  Index,
PULONG  Irq 
)

Definition at line 714 of file machpc.c.

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

Referenced by DetectIsaBios().

◆ PcHwDetect()

Definition at line 1631 of file machpc.c.

1632{
1634 ULONG BusNumber = 0;
1635
1636 TRACE("DetectHardware()\n");
1637
1638 /* Create the 'System' key */
1639 // TODO: Discover and set the other machine types
1640 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
1641
1644
1645 /* Detect buses */
1646 DetectPciBios(SystemKey, &BusNumber);
1647 DetectApmBios(SystemKey, &BusNumber);
1648 DetectPnpBios(SystemKey, &BusNumber);
1649 DetectIsaBios(SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
1650 DetectAcpiBios(SystemKey, &BusNumber);
1651
1652 // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
1653 // CM_ROM_BLOCK data into the 'System' key's configuration data.
1654
1655 TRACE("DetectHardware() Done\n");
1656 return SystemKey;
1657}
VOID FldrCreateSystemKey(_Out_ PCONFIGURATION_COMPONENT_DATA *SystemNode, _In_ PCSTR IdentifierString)
Definition: archwsup.c:135
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwacpi.c:54
VOID DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwpci.c:176
BOOLEAN PcFindPciBios(PPCI_REGISTRY_INFO BusData)
Definition: hwpci.c:80
FIND_PCI_BIOS FindPciBios
Definition: hwpci.c:26
VOID DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwapm.c:46
static VOID DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: machpc.c:253
static VOID DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: machpc.c:1564
static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: machpc.c:118
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 1660 of file machpc.c.

1661{
1662 REGS Regs;
1663
1664 /* Select APM 1.0+ function */
1665 Regs.b.ah = 0x53;
1666
1667 /* Function 05h: CPU idle */
1668 Regs.b.al = 0x05;
1669
1670 /* Call INT 15h */
1671 Int386(0x15, &Regs, &Regs);
1672
1673 /* Check if successfull (CF set on error) */
1674 if (INT386_SUCCESS(Regs))
1675 return;
1676
1677 /*
1678 * No futher processing here.
1679 * Optionally implement HLT instruction handling.
1680 */
1681}

Referenced by MachInit().

◆ PcPrepareForReactOS()

VOID PcPrepareForReactOS ( VOID  )

Definition at line 1752 of file machpc.c.

1753{
1754 /* On PC, prepare video and turn off the floppy motor */
1757}
VOID __cdecl DiskStopFloppyMotor(VOID)
Definition: pc98hw.c:1234
VOID PcVideoPrepareForReactOS(VOID)
Definition: pcvideo.c:1161

Referenced by MachInit().

◆ PS2ControllerWait()

static VOID PS2ControllerWait ( VOID  )
static

Definition at line 1120 of file machpc.c.

1121{
1122 ULONG Timeout;
1123 UCHAR Status;
1124
1126 {
1129 return;
1130
1131 /* Sleep for one millisecond */
1133 }
1134}
#define CONTROLLER_STATUS_INPUT_BUFFER_FULL
Definition: machpc.c:79
#define CONTROLLER_TIMEOUT
Definition: machpc.c:90
static ULONG Timeout
Definition: ping.c:61

Referenced by DetectPS2AuxDevice(), and DetectPS2AuxPort().