ReactOS 0.4.15-dev-5666-gc548b97
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 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:69
#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL
Definition: machpc.c:64

Definition at line 72 of file machpc.c.

◆ CONTROLLER_COMMAND_GET_VERSION

#define CONTROLLER_COMMAND_GET_VERSION   0xA1

Definition at line 52 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_DISABLE

#define CONTROLLER_COMMAND_KEYBOARD_DISABLE   0xAD

Definition at line 58 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_ENABLE

#define CONTROLLER_COMMAND_KEYBOARD_ENABLE   0xAE

Definition at line 59 of file machpc.c.

◆ CONTROLLER_COMMAND_KEYBOARD_TEST

#define CONTROLLER_COMMAND_KEYBOARD_TEST   0xAB

Definition at line 57 of file machpc.c.

◆ CONTROLLER_COMMAND_MOUSE_DISABLE

#define CONTROLLER_COMMAND_MOUSE_DISABLE   0xA7

Definition at line 53 of file machpc.c.

◆ CONTROLLER_COMMAND_MOUSE_ENABLE

#define CONTROLLER_COMMAND_MOUSE_ENABLE   0xA8

Definition at line 54 of file machpc.c.

◆ CONTROLLER_COMMAND_READ_MODE

#define CONTROLLER_COMMAND_READ_MODE   0x20

Definition at line 50 of file machpc.c.

◆ CONTROLLER_COMMAND_SELF_TEST

#define CONTROLLER_COMMAND_SELF_TEST   0xAA

Definition at line 56 of file machpc.c.

◆ CONTROLLER_COMMAND_TEST_MOUSE

#define CONTROLLER_COMMAND_TEST_MOUSE   0xA9

Definition at line 55 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MODE

#define CONTROLLER_COMMAND_WRITE_MODE   0x60

Definition at line 51 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MOUSE

#define CONTROLLER_COMMAND_WRITE_MOUSE   0xD4

Definition at line 61 of file machpc.c.

◆ CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER

#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER   0xD3

Definition at line 60 of file machpc.c.

◆ CONTROLLER_REGISTER_CONTROL

#define CONTROLLER_REGISTER_CONTROL   0x64

Definition at line 46 of file machpc.c.

◆ CONTROLLER_REGISTER_DATA

#define CONTROLLER_REGISTER_DATA   0x60

Definition at line 47 of file machpc.c.

◆ CONTROLLER_REGISTER_STATUS

#define CONTROLLER_REGISTER_STATUS   0x64

Definition at line 45 of file machpc.c.

◆ CONTROLLER_STATUS_COMMAND

#define CONTROLLER_STATUS_COMMAND   0x08

Definition at line 67 of file machpc.c.

◆ CONTROLLER_STATUS_GENERAL_TIMEOUT

#define CONTROLLER_STATUS_GENERAL_TIMEOUT   0x40

Definition at line 70 of file machpc.c.

◆ CONTROLLER_STATUS_INPUT_BUFFER_FULL

#define CONTROLLER_STATUS_INPUT_BUFFER_FULL   0x02

Definition at line 65 of file machpc.c.

◆ CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL

#define CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL   0x20

Definition at line 69 of file machpc.c.

◆ CONTROLLER_STATUS_OUTPUT_BUFFER_FULL

#define CONTROLLER_STATUS_OUTPUT_BUFFER_FULL   0x01

Definition at line 64 of file machpc.c.

◆ CONTROLLER_STATUS_PARITY_ERROR

#define CONTROLLER_STATUS_PARITY_ERROR   0x80

Definition at line 71 of file machpc.c.

◆ CONTROLLER_STATUS_SELF_TEST

#define CONTROLLER_STATUS_SELF_TEST   0x04

Definition at line 66 of file machpc.c.

◆ CONTROLLER_STATUS_UNLOCKED

#define CONTROLLER_STATUS_UNLOCKED   0x10

Definition at line 68 of file machpc.c.

◆ CONTROLLER_TIMEOUT

#define CONTROLLER_TIMEOUT   250

Definition at line 76 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.

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 1482 of file machpc.c.

1485{
1486 REGS Regs;
1487
1488 RtlZeroMemory(&Regs, sizeof(Regs));
1489
1490 /* Set the boot drive and the boot partition */
1491 Regs.b.dl = (UCHAR)(BootDrive ? BootDrive : FrldrBootDrive);
1492 Regs.b.dh = (UCHAR)(BootPartition ? BootPartition : FrldrBootPartition);
1493
1494 /*
1495 * Don't stop the floppy drive motor when we are just booting a bootsector,
1496 * a drive, or a partition. If we were to stop the floppy motor, the BIOS
1497 * wouldn't be informed and if the next read is to a floppy then the BIOS
1498 * will still think the motor is on and this will result in a read error.
1499 */
1500 // DiskStopFloppyMotor();
1501
1502 Relocator16Boot(&Regs,
1503 /* Stack segment:pointer */
1504 0x0000, 0x7C00,
1505 /* Code segment:pointer */
1506 0x0000, 0x7C00);
1507}
UCHAR FrldrBootDrive
ULONG FrldrBootPartition
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
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 1307 of file machpc.c.

1308{
1309 CHAR Buffer[80];
1310 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1311 USHORT VesaVersion;
1312
1313 /* FIXME: Set 'ComponentInformation' value */
1314
1315 VesaVersion = BiosIsVesaSupported();
1316 if (VesaVersion != 0)
1317 {
1318 TRACE("VESA version %c.%c\n",
1319 (VesaVersion >> 8) + '0',
1320 (VesaVersion & 0xFF) + '0');
1321 }
1322 else
1323 {
1324 TRACE("VESA not supported\n");
1325 }
1326
1327 if (VesaVersion >= 0x0200)
1328 {
1329 strcpy(Buffer, "VBE Display");
1330 }
1331 else
1332 {
1333 strcpy(Buffer, "VGA Display");
1334 }
1335
1338 DisplayController,
1339 0x0,
1340 0x0,
1341 0xFFFFFFFF,
1342 Buffer,
1343 NULL,
1344 0,
1345 &ControllerKey);
1346 TRACE("Created key: DisplayController\\0\n");
1347
1348 /* FIXME: Add display peripheral (monitor) data */
1349 if (VesaVersion != 0)
1350 {
1352 {
1353 TRACE("VESA/DDC supported!\n");
1354 if (BiosVesaReadEdid())
1355 {
1356 TRACE("EDID data read successfully!\n");
1357
1358 }
1359 }
1360 }
1361}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
VOID NTAPI 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 PCHAR IdentifierString, IN PCM_PARTIAL_RESOURCE_LIST ResourceList, IN ULONG Size, OUT PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:147
Definition: bufpool.h:45
#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
char CHAR
Definition: xmlstorage.h:175

Referenced by DetectIsaBios().

◆ DetectDockingStation()

static VOID DetectDockingStation ( _Inout_ PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 182 of file machpc.c.

184{
185 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
186 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
187 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
188 PDOCKING_STATE_INFORMATION DockingState;
190
192
193 /* Build full device descriptor */
196 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
197 if (PartialResourceList == NULL)
198 {
199 ERR("Failed to allocate resource descriptor\n");
200 return;
201 }
202
203 /* Initialize resource descriptor */
204 RtlZeroMemory(PartialResourceList, Size);
205 PartialResourceList->Version = 0;
206 PartialResourceList->Revision = 0;
207 PartialResourceList->Count = 1;
208
209 /* Set device specific data */
210 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
211 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
213 PartialDescriptor->Flags = 0;
214 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(DOCKING_STATE_INFORMATION);
215
216 DockingState = (PDOCKING_STATE_INFORMATION)&PartialResourceList->PartialDescriptors[1];
217 DockingState->ReturnCode = Result;
218 if (Result == 0)
219 {
220 /* FIXME: Add more device specific data */
221 ERR("FIXME: System docked\n");
222 }
223
224 /* Create controller key */
227 DockingInformation,
228 0,
229 0,
230 0xFFFFFFFF,
231 "Docking State Information",
232 PartialResourceList,
233 Size,
234 &PeripheralKey);
235}
#define DiskReadBuffer
Definition: hardware.h:33
#define TAG_HW_RESOURCE_LIST
Definition: hardware.h:23
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
unsigned int ULONG
Definition: retypes.h:1
struct _DOCKING_STATE_INFORMATION DOCKING_STATE_INFORMATION
struct _DOCKING_STATE_INFORMATION * PDOCKING_STATE_INFORMATION
@ PeripheralClass
Definition: arc.h:95
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381::@390 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381 u
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
_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:426
@ CmResourceShareUndetermined
Definition: cmtypes.h:240

Referenced by DetectPnpBios().

◆ DetectIsaBios()

static VOID DetectIsaBios ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
ULONG BusNumber 
)
static

Definition at line 1365 of file machpc.c.

1366{
1367 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1369 ULONG Size;
1370
1371 /* Set 'Configuration Data' value */
1372 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1374 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1375 if (PartialResourceList == NULL)
1376 {
1377 ERR("Failed to allocate resource descriptor\n");
1378 return;
1379 }
1380
1381 /* Initialize resource descriptor */
1382 RtlZeroMemory(PartialResourceList, Size);
1383 PartialResourceList->Version = 1;
1384 PartialResourceList->Revision = 1;
1385 PartialResourceList->Count = 0;
1386
1387 /* Create new bus key */
1388 FldrCreateComponentKey(SystemKey,
1390 MultiFunctionAdapter,
1391 0x0,
1392 0x0,
1393 0xFFFFFFFF,
1394 "ISA",
1395 PartialResourceList,
1396 Size,
1397 &BusKey);
1398
1399 /* Increment bus number */
1400 (*BusNumber)++;
1401
1402 /* Detect ISA/BIOS devices */
1403 DetectBiosDisks(SystemKey, BusKey);
1405 DetectParallelPorts(BusKey);
1407 DetectPS2Mouse(BusKey);
1409
1410 /* FIXME: Detect more ISA devices */
1411}
ULONG PcGetSerialPort(ULONG Index, PULONG Irq)
Definition: machpc.c:702
#define MAX_COM_PORTS
Definition: machpc.c:27
static VOID DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1042
VOID DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey, GET_SERIAL_PORT MachGetSerialPort, ULONG Count)
Definition: machpc.c:719
static VOID DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1220
static VOID DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:815
static VOID DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: machpc.c:1307
VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pchw.c:345
@ AdapterClass
Definition: arc.h:93

Referenced by PcHwDetect().

◆ DetectKeyboardController()

static VOID DetectKeyboardController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1042 of file machpc.c.

1043{
1044 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1045 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
1046 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1047 ULONG Size;
1048
1049 /* Set 'Configuration Data' value */
1050 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
1052 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1053 if (PartialResourceList == NULL)
1054 {
1055 ERR("Failed to allocate resource descriptor\n");
1056 return;
1057 }
1058
1059 /* Initialize resource descriptor */
1060 RtlZeroMemory(PartialResourceList, Size);
1061 PartialResourceList->Version = 1;
1062 PartialResourceList->Revision = 1;
1063 PartialResourceList->Count = 3;
1064
1065 /* Set Interrupt */
1066 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
1067 PartialDescriptor->Type = CmResourceTypeInterrupt;
1068 PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
1069 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1070 PartialDescriptor->u.Interrupt.Level = 1;
1071 PartialDescriptor->u.Interrupt.Vector = 1;
1072 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
1073
1074 /* Set IO Port 0x60 */
1075 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
1076 PartialDescriptor->Type = CmResourceTypePort;
1078 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1079 PartialDescriptor->u.Port.Start.LowPart = 0x60;
1080 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1081 PartialDescriptor->u.Port.Length = 1;
1082
1083 /* Set IO Port 0x64 */
1084 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
1085 PartialDescriptor->Type = CmResourceTypePort;
1087 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
1088 PartialDescriptor->u.Port.Start.LowPart = 0x64;
1089 PartialDescriptor->u.Port.Start.HighPart = 0x0;
1090 PartialDescriptor->u.Port.Length = 1;
1091
1092 /* Create controller key */
1095 KeyboardController,
1096 Input | ConsoleIn,
1097 0x0,
1098 0xFFFFFFFF,
1099 NULL,
1100 PartialResourceList,
1101 Size,
1102 &ControllerKey);
1103 TRACE("Created key: KeyboardController\\0\n");
1104
1105 DetectKeyboardPeripheral(ControllerKey);
1106}
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
static VOID DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: machpc.c:976
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
@ ConsoleIn
Definition: arc.h:82
@ Input
Definition: arc.h:84
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381::@383 Port
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381::@384 Interrupt
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241

Referenced by DetectIsaBios().

◆ DetectKeyboardDevice()

BOOLEAN DetectKeyboardDevice ( VOID  )

Definition at line 907 of file machpc.c.

908{
910 UCHAR Scancode;
911 ULONG Loops;
913
914 /* Identify device */
916
917 /* Wait for reply */
918 for (Loops = 0; Loops < 100; Loops++)
919 {
923 break;
924 }
925
927 {
928 /* PC/XT keyboard or no keyboard */
929 Result = FALSE;
930 }
931
933 if (Scancode != 0xFA)
934 {
935 /* No ACK received */
936 Result = FALSE;
937 }
938
940
943 {
944 /* Found AT keyboard */
945 return Result;
946 }
947
949 if (Scancode != 0xAB)
950 {
951 /* No 0xAB received */
952 Result = FALSE;
953 }
954
956
959 {
960 /* No byte in buffer */
961 Result = FALSE;
962 }
963
965 if (Scancode != 0x41)
966 {
967 /* No 0x41 received */
968 Result = FALSE;
969 }
970
971 /* Found MF-II keyboard */
972 return Result;
973}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
Status
Definition: gdiplustypes.h:25
unsigned char * PUCHAR
Definition: retypes.h:3
#define CONTROLLER_REGISTER_STATUS
Definition: machpc.c:45
#define CONTROLLER_REGISTER_DATA
Definition: machpc.c:47
#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

◆ DetectKeyboardPeripheral()

static VOID DetectKeyboardPeripheral ( PCONFIGURATION_COMPONENT_DATA  ControllerKey)
static

Definition at line 976 of file machpc.c.

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

816{
817 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
818 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
819 ULONG Irq[MAX_LPT_PORTS] = {7, 5, (ULONG) - 1};
820 CHAR Buffer[80];
821 PCONFIGURATION_COMPONENT_DATA ControllerKey;
822 PUSHORT BasePtr;
823 ULONG Base;
824 ULONG ControllerNumber = 0;
825 ULONG i;
826 ULONG Size;
827
828 TRACE("DetectParallelPorts() called\n");
829
830 /*
831 * The BIOS data area 0x408 holds the address of the first valid LPT port.
832 * Each LPT port address is stored in a 2-byte field.
833 * Infos at: http://www.bioscentral.com/misc/bda.htm
834 */
835 BasePtr = (PUSHORT)0x408;
836
837 for (i = 0; i < MAX_LPT_PORTS; i++, BasePtr++)
838 {
839 Base = (ULONG) * BasePtr;
840 if (Base == 0)
841 continue;
842
843 TRACE("Parallel port %u: %x\n", ControllerNumber, Base);
844
845 /* Set 'Identifier' value */
846 sprintf(Buffer, "PARALLEL%ld", i + 1);
847
848 /* Build full device descriptor */
850 if (Irq[i] != (ULONG) - 1)
852
853 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
854 if (PartialResourceList == NULL)
855 {
856 ERR("Failed to allocate resource descriptor! Ignoring remaining parallel ports. (i = %lu)\n", i);
857 break;
858 }
859
860 /* Initialize resource descriptor */
861 RtlZeroMemory(PartialResourceList, Size);
862 PartialResourceList->Version = 1;
863 PartialResourceList->Revision = 1;
864 PartialResourceList->Count = (Irq[i] != (ULONG) - 1) ? 2 : 1;
865
866 /* Set IO Port */
867 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
868 PartialDescriptor->Type = CmResourceTypePort;
870 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
871 PartialDescriptor->u.Port.Start.LowPart = Base;
872 PartialDescriptor->u.Port.Start.HighPart = 0x0;
873 PartialDescriptor->u.Port.Length = 3;
874
875 /* Set Interrupt */
876 if (Irq[i] != (ULONG) - 1)
877 {
878 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
879 PartialDescriptor->Type = CmResourceTypeInterrupt;
881 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
882 PartialDescriptor->u.Interrupt.Level = Irq[i];
883 PartialDescriptor->u.Interrupt.Vector = Irq[i];
884 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
885 }
886
887 /* Create controller key */
890 ParallelController,
891 Output,
892 ControllerNumber,
893 0xFFFFFFFF,
894 Buffer,
895 PartialResourceList,
896 Size,
897 &ControllerKey);
898
899 ControllerNumber++;
900 }
901
902 TRACE("DetectParallelPorts() done\n");
903}
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
unsigned short * PUSHORT
Definition: retypes.h:2
#define MAX_LPT_PORTS
Definition: machpc.c:28
#define sprintf(buf, format,...)
Definition: sprintf.c:55
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2427
@ Output
Definition: arc.h:85

Referenced by DetectIsaBios().

◆ DetectPnpBios()

static VOID DetectPnpBios ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
ULONG BusNumber 
)
static

Definition at line 239 of file machpc.c.

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

Referenced by PcHwDetect().

◆ DetectPS2AuxDevice()

static BOOLEAN DetectPS2AuxDevice ( VOID  )
static

Definition at line 1171 of file machpc.c.

1172{
1173 UCHAR Scancode;
1174 UCHAR Status;
1175 ULONG Loops;
1177
1182
1183 /* Identify device */
1185
1186 /* Wait for reply */
1187 for (Loops = 0; Loops < 100; Loops++)
1188 {
1192 break;
1193 }
1194
1197 Result = FALSE;
1198
1200 if (Scancode != 0xFA)
1201 Result = FALSE;
1202
1204
1207 Result = FALSE;
1208
1210 if (Scancode != 0x00)
1211 Result = FALSE;
1212
1213 return Result;
1214}
#define CONTROLLER_COMMAND_WRITE_MOUSE
Definition: machpc.c:61
static VOID PS2ControllerWait(VOID)
Definition: machpc.c:1110
#define CONTROLLER_REGISTER_CONTROL
Definition: machpc.c:46

Referenced by DetectPS2Mouse().

◆ DetectPS2AuxPort()

static BOOLEAN DetectPS2AuxPort ( VOID  )
static

Definition at line 1128 of file machpc.c.

1129{
1130#if 1
1131 /* Current detection is too unreliable. Just do as if
1132 * the PS/2 aux port is always present
1133 */
1134 return TRUE;
1135#else
1136 ULONG Loops;
1137 UCHAR Status;
1138
1139 /* Put the value 0x5A in the output buffer using the
1140 * "WriteAuxiliary Device Output Buffer" command (0xD3).
1141 * Poll the Status Register for a while to see if the value really turns up
1142 * in the Data Register. If the KEYBOARD_STATUS_MOUSE_OBF bit is also set
1143 * to 1 in the Status Register, we assume this controller has an
1144 * Auxiliary Port (a.k.a. Mouse Port).
1145 */
1150
1151 /* 0x5A is a random dummy value */
1153 0x5A);
1154
1155 for (Loops = 0; Loops < 10; Loops++)
1156 {
1160 break;
1161 }
1162
1164
1166#endif
1167}
#define CONTROLLER_COMMAND_WRITE_MOUSE_OUTPUT_BUFFER
Definition: machpc.c:60

Referenced by DetectPS2Mouse().

◆ DetectPS2Mouse()

static VOID DetectPS2Mouse ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 1220 of file machpc.c.

1221{
1222 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1223 PCONFIGURATION_COMPONENT_DATA ControllerKey;
1224 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
1225 ULONG Size;
1226
1227 if (DetectPS2AuxPort())
1228 {
1229 TRACE("Detected PS2 port\n");
1230
1231 PartialResourceList = FrLdrHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST), TAG_HW_RESOURCE_LIST);
1232 if (PartialResourceList == NULL)
1233 {
1234 ERR("Failed to allocate resource descriptor\n");
1235 return;
1236 }
1237
1238 /* Initialize resource descriptor */
1239 RtlZeroMemory(PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST));
1240 PartialResourceList->Version = 1;
1241 PartialResourceList->Revision = 1;
1242 PartialResourceList->Count = 1;
1243
1244 /* Set Interrupt */
1245 PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeInterrupt;
1247 PartialResourceList->PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LATCHED;
1248 PartialResourceList->PartialDescriptors[0].u.Interrupt.Level = 12;
1249 PartialResourceList->PartialDescriptors[0].u.Interrupt.Vector = 12;
1250 PartialResourceList->PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF;
1251
1252 /* Create controller key */
1255 PointerController,
1256 Input,
1257 0x0,
1258 0xFFFFFFFF,
1259 NULL,
1260 PartialResourceList,
1262 &ControllerKey);
1263 TRACE("Created key: PointerController\\0\n");
1264
1265 if (DetectPS2AuxDevice())
1266 {
1267 TRACE("Detected PS2 mouse\n");
1268
1269 /* Initialize resource descriptor */
1270 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1272 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1273 if (PartialResourceList == NULL)
1274 {
1275 ERR("Failed to allocate resource descriptor\n");
1276 return;
1277 }
1278
1279 RtlZeroMemory(PartialResourceList, Size);
1280 PartialResourceList->Version = 1;
1281 PartialResourceList->Revision = 1;
1282 PartialResourceList->Count = 0;
1283
1284 /* Create peripheral key */
1285 FldrCreateComponentKey(ControllerKey,
1287 PointerPeripheral,
1288 Input,
1289 0x0,
1290 0xFFFFFFFF,
1291 "MICROSOFT PS2 MOUSE",
1292 PartialResourceList,
1293 Size,
1294 &PeripheralKey);
1295 TRACE("Created key: PointerPeripheral\\0\n");
1296 }
1297 }
1298}
static BOOLEAN DetectPS2AuxDevice(VOID)
Definition: machpc.c:1171
static BOOLEAN DetectPS2AuxPort(VOID)
Definition: machpc.c:1128

Referenced by DetectIsaBios().

◆ DetectSerialMouse()

static ULONG DetectSerialMouse ( PUCHAR  Port)
static

Definition at line 389 of file machpc.c.

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

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

720{
721 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
722 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
723 PCM_SERIAL_DEVICE_DATA SerialDeviceData;
724 ULONG Irq;
725 ULONG Base;
726 CHAR Buffer[80];
727 ULONG ControllerNumber = 0;
728 PCONFIGURATION_COMPONENT_DATA ControllerKey;
729 ULONG i;
730 ULONG Size;
731
732 TRACE("DetectSerialPorts()\n");
733
734 for (i = 0; i < Count; i++)
735 {
736 Base = MachGetSerialPort(i, &Irq);
737 if ((Base == 0) || !CpDoesPortExist(UlongToPtr(Base)))
738 continue;
739
740 TRACE("Found COM%u port at 0x%x\n", i + 1, Base);
741
742 /* Set 'Identifier' value */
743 sprintf(Buffer, "COM%ld", i + 1);
744
745 /* Build full device descriptor */
748 sizeof(CM_SERIAL_DEVICE_DATA);
749 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
750 if (PartialResourceList == NULL)
751 {
752 ERR("Failed to allocate resource descriptor! Ignoring remaining serial ports. (i = %lu, Count = %lu)\n",
753 i, Count);
754 break;
755 }
756
757 /* Initialize resource descriptor */
758 RtlZeroMemory(PartialResourceList, Size);
759 PartialResourceList->Version = 1;
760 PartialResourceList->Revision = 1;
761 PartialResourceList->Count = 3;
762
763 /* Set IO Port */
764 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
765 PartialDescriptor->Type = CmResourceTypePort;
767 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
768 PartialDescriptor->u.Port.Start.LowPart = Base;
769 PartialDescriptor->u.Port.Start.HighPart = 0x0;
770 PartialDescriptor->u.Port.Length = 8;
771
772 /* Set Interrupt */
773 PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
774 PartialDescriptor->Type = CmResourceTypeInterrupt;
776 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
777 PartialDescriptor->u.Interrupt.Level = Irq;
778 PartialDescriptor->u.Interrupt.Vector = Irq;
779 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
780
781 /* Set serial data (device specific) */
782 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
783 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
785 PartialDescriptor->Flags = 0;
786 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_SERIAL_DEVICE_DATA);
787
788 SerialDeviceData =
789 (PCM_SERIAL_DEVICE_DATA)&PartialResourceList->PartialDescriptors[3];
790 SerialDeviceData->BaudClock = 1843200; /* UART Clock frequency (Hertz) */
791
792 /* Create controller key */
795 SerialController,
797 ControllerNumber,
798 0xFFFFFFFF,
799 Buffer,
800 PartialResourceList,
801 Size,
802 &ControllerKey);
803
805 {
806 /* Detect serial mouse */
808 }
809
810 ControllerNumber++;
811 }
812}
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:542
int Count
Definition: noreturn.cpp:7
@ ConsoleOut
Definition: arc.h:83
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 482 of file machpc.c.

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

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

Referenced by DetectSerialPointerPeripheral().

◆ MachInit()

VOID MachInit ( const char CmdLine)

Definition at line 1514 of file machpc.c.

1515{
1516 /* Setup vtbl */
1517 RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
1546
1548}
MACHVTBL MachVtbl
Definition: arcemul.c:21
BOOLEAN PcInitializeBootDevices(VOID)
Definition: hwdisk.c:470
VOID PcGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
Definition: machpc.c:80
PCONFIGURATION_COMPONENT_DATA PcHwDetect(VOID)
Definition: machpc.c:1429
static UCHAR PcGetFloppyCount(VOID)
Definition: machpc.c:1417
VOID PcHwIdle(VOID)
Definition: machpc.c:1459
VOID PcPrepareForReactOS(VOID)
Definition: machpc.c:1551
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 80 of file machpc.c.

81{
82 REGS BiosRegs;
83
84 /* Get address and size of the extended BIOS data area */
85 BiosRegs.d.eax = 0xC100;
86 Int386(0x15, &BiosRegs, &BiosRegs);
87 if (INT386_SUCCESS(BiosRegs))
88 {
89 *ExtendedBIOSDataArea = BiosRegs.w.es << 4;
91 }
92 else
93 {
94 WARN("Int 15h AH=C1h call failed\n");
97 }
98}
#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 1417 of file machpc.c.

1418{
1419 UCHAR Data;
1420
1421 WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
1422 Data = READ_PORT_UCHAR((PUCHAR)0x71);
1423
1424 return ((Data & 0xF0) ? 1 : 0) + ((Data & 0x0F) ? 1 : 0);
1425}

Referenced by MachInit().

◆ PcGetHarddiskConfigurationData()

static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData ( UCHAR  DriveNumber,
ULONG pSize 
)
static

Definition at line 104 of file machpc.c.

105{
106 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
108 // EXTENDED_GEOMETRY ExtGeometry;
109 GEOMETRY Geometry;
110 ULONG Size;
111
112 //
113 // Initialize returned size
114 //
115 *pSize = 0;
116
117 /* Set 'Configuration Data' value */
120 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
121 if (PartialResourceList == NULL)
122 {
123 ERR("Failed to allocate resource descriptor\n");
124 return NULL;
125 }
126
127 RtlZeroMemory(PartialResourceList, Size);
128 PartialResourceList->Version = 1;
129 PartialResourceList->Revision = 1;
130 PartialResourceList->Count = 1;
131 PartialResourceList->PartialDescriptors[0].Type =
133// PartialResourceList->PartialDescriptors[0].ShareDisposition =
134// PartialResourceList->PartialDescriptors[0].Flags =
135 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
137
138 /* Get pointer to geometry data */
139 DiskGeometry = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
140
141 /* Get the disk geometry */
142#if 0 // This is somehow replaced by what PcDiskGetDriveGeometry() does internally.
143 ExtGeometry.Size = sizeof(EXTENDED_GEOMETRY);
144 if (DiskGetExtendedDriveParameters(DriveNumber, &ExtGeometry, ExtGeometry.Size))
145 {
146 DiskGeometry->BytesPerSector = ExtGeometry.BytesPerSector;
147 DiskGeometry->NumberOfCylinders = ExtGeometry.Cylinders;
148 DiskGeometry->SectorsPerTrack = ExtGeometry.SectorsPerTrack;
149 DiskGeometry->NumberOfHeads = ExtGeometry.Heads;
150 }
151 else
152#endif
153 if (PcDiskGetDriveGeometry(DriveNumber, &Geometry))
154 {
155 DiskGeometry->BytesPerSector = Geometry.BytesPerSector;
156 DiskGeometry->NumberOfCylinders = Geometry.Cylinders;
157 DiskGeometry->SectorsPerTrack = Geometry.Sectors;
158 DiskGeometry->NumberOfHeads = Geometry.Heads;
159 }
160 else
161 {
162 TRACE("Reading disk geometry failed\n");
163 FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
164 return NULL;
165 }
166 TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
167 DriveNumber,
168 DiskGeometry->NumberOfCylinders,
169 DiskGeometry->NumberOfHeads,
170 DiskGeometry->SectorsPerTrack,
171 DiskGeometry->BytesPerSector);
172
173 //
174 // Return configuration data
175 //
176 *pSize = Size;
177 return PartialResourceList;
178}
struct _EXTENDED_GEOMETRY EXTENDED_GEOMETRY
FORCEINLINE VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: mm.h:181
void * PVOID
Definition: retypes.h:9
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
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 702 of file machpc.c.

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

Referenced by DetectIsaBios().

◆ PcHwDetect()

Definition at line 1429 of file machpc.c.

1430{
1432 ULONG BusNumber = 0;
1433
1434 TRACE("DetectHardware()\n");
1435
1436 /* Create the 'System' key */
1437 FldrCreateSystemKey(&SystemKey);
1438 // TODO: Discover and set the other machine types
1439 FldrSetIdentifier(SystemKey, "AT/AT COMPATIBLE");
1440
1443
1444 /* Detect buses */
1445 DetectPciBios(SystemKey, &BusNumber);
1446 DetectApmBios(SystemKey, &BusNumber);
1447 DetectPnpBios(SystemKey, &BusNumber);
1448 DetectIsaBios(SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
1449 DetectAcpiBios(SystemKey, &BusNumber);
1450
1451 // TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
1452 // CM_ROM_BLOCK data into the 'System' key's configuration data.
1453
1454 TRACE("DetectHardware() Done\n");
1455 return SystemKey;
1456}
VOID NTAPI FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData, IN PCHAR IdentifierString)
Definition: archwsup.c:56
VOID NTAPI FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode)
Definition: archwsup.c:89
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:239
static VOID DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: machpc.c:1365
static PCM_PARTIAL_RESOURCE_LIST PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: machpc.c:104
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 1459 of file machpc.c.

1460{
1461 REGS Regs;
1462
1463 /* Select APM 1.0+ function */
1464 Regs.b.ah = 0x53;
1465
1466 /* Function 05h: CPU idle */
1467 Regs.b.al = 0x05;
1468
1469 /* Call INT 15h */
1470 Int386(0x15, &Regs, &Regs);
1471
1472 /* Check if successfull (CF set on error) */
1473 if (INT386_SUCCESS(Regs))
1474 return;
1475
1476 /*
1477 * No futher processing here.
1478 * Optionally implement HLT instruction handling.
1479 */
1480}

Referenced by MachInit().

◆ PcPrepareForReactOS()

VOID PcPrepareForReactOS ( VOID  )

Definition at line 1551 of file machpc.c.

1552{
1553 /* On PC, prepare video and turn off the floppy motor */
1556}
VOID __cdecl DiskStopFloppyMotor(VOID)
Definition: pc98hw.c:1245
VOID PcVideoPrepareForReactOS(VOID)
Definition: pcvideo.c:1161

Referenced by MachInit().

◆ PS2ControllerWait()

static VOID PS2ControllerWait ( VOID  )
static

Definition at line 1110 of file machpc.c.

1111{
1112 ULONG Timeout;
1113 UCHAR Status;
1114
1116 {
1119 return;
1120
1121 /* Sleep for one millisecond */
1123 }
1124}
#define CONTROLLER_STATUS_INPUT_BUFFER_FULL
Definition: machpc.c:65
#define CONTROLLER_TIMEOUT
Definition: machpc.c:76
static ULONG Timeout
Definition: ping.c:61

Referenced by DetectPS2AuxDevice(), and DetectPS2AuxPort().