ReactOS  0.4.13-dev-257-gfabbd7c
hardware.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for hardware.c:

Go to the source code of this file.

Macros

#define MILLISEC   (10)
 
#define PRECISION   (8)
 
#define HZ   (100)
 
#define CLOCK_TICK_RATE   (1193182)
 
#define LATCH   (CLOCK_TICK_RATE / HZ)
 

Functions

 DBG_DEFAULT_CHANNEL (HWDETECT)
 
PCHAR GetHarddiskIdentifier (UCHAR DriveNumber)
 
static VOID __StallExecutionProcessor (ULONG Loops)
 
VOID StallExecutionProcessor (ULONG Microseconds)
 
static ULONG Read8254Timer (VOID)
 
static VOID WaitFor8254Wraparound (VOID)
 
VOID HalpCalibrateStallExecution (VOID)
 
static UCHAR GetFloppyCount (VOID)
 
static UCHAR GetFloppyType (UCHAR DriveNumber)
 
static PVOID GetInt1eTable (VOID)
 
static VOID DetectBiosFloppyPeripheral (PCONFIGURATION_COMPONENT_DATA ControllerKey)
 
static PCONFIGURATION_COMPONENT_DATA DetectBiosFloppyController (PCONFIGURATION_COMPONENT_DATA BusKey)
 
VOID DetectBiosDisks (PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
 
VOID FrLdrCheckCpuCompatibility (VOID)
 

Variables

static unsigned int delay_count = 1
 
UCHAR PcBiosDiskCount
 
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData = NULL
 

Macro Definition Documentation

◆ CLOCK_TICK_RATE

#define CLOCK_TICK_RATE   (1193182)

Definition at line 33 of file hardware.c.

◆ HZ

#define HZ   (100)

Definition at line 32 of file hardware.c.

◆ LATCH

#define LATCH   (CLOCK_TICK_RATE / HZ)

Definition at line 34 of file hardware.c.

◆ MILLISEC

#define MILLISEC   (10)

Definition at line 29 of file hardware.c.

◆ PRECISION

#define PRECISION   (8)

Definition at line 30 of file hardware.c.

Function Documentation

◆ __StallExecutionProcessor()

static VOID __StallExecutionProcessor ( ULONG  Loops)
static

Definition at line 51 of file hardware.c.

52 {
53  register volatile unsigned int i;
54  for (i = 0; i < Loops; i++);
55 }
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

Referenced by HalpCalibrateStallExecution(), and StallExecutionProcessor().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( HWDETECT  )

◆ DetectBiosDisks()

VOID DetectBiosDisks ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
PCONFIGURATION_COMPONENT_DATA  BusKey 
)

Definition at line 353 of file hardware.c.

355 {
356  PCONFIGURATION_COMPONENT_DATA ControllerKey, DiskKey;
357  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
358  PCM_INT13_DRIVE_PARAMETER Int13Drives;
359  GEOMETRY Geometry;
360  UCHAR DiskCount, DriveNumber;
361  USHORT i;
362  ULONG Size;
363 
364  /* The pre-enumeration of the BIOS disks was already done in InitializeBootDevices() */
365  DiskCount = PcBiosDiskCount;
366 
367  /* Use the floppy disk controller as our controller */
368  ControllerKey = DetectBiosFloppyController(BusKey);
369  if (!ControllerKey)
370  {
371  ERR("Failed to detect BIOS disk controller\n");
372  return;
373  }
374 
375  /* Allocate resource descriptor */
376  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
377  sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
378  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
379  if (PartialResourceList == NULL)
380  {
381  ERR("Failed to allocate resource descriptor\n");
382  return;
383  }
384 
385  /* Initialize resource descriptor */
386  memset(PartialResourceList, 0, Size);
387  PartialResourceList->Version = 1;
388  PartialResourceList->Revision = 1;
389  PartialResourceList->Count = 1;
390  PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeDeviceSpecific;
391  PartialResourceList->PartialDescriptors[0].ShareDisposition = 0;
392  PartialResourceList->PartialDescriptors[0].Flags = 0;
393  PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
394  sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
395 
396  /* Get harddisk Int13 geometry data */
397  Int13Drives = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
398  for (i = 0; i < DiskCount; i++)
399  {
400  DriveNumber = 0x80 + i;
401 
402  if (MachDiskGetDriveGeometry(DriveNumber, &Geometry))
403  {
404  Int13Drives[i].DriveSelect = DriveNumber;
405  Int13Drives[i].MaxCylinders = Geometry.Cylinders - 1;
406  Int13Drives[i].SectorsPerTrack = (USHORT)Geometry.Sectors;
407  Int13Drives[i].MaxHeads = (USHORT)Geometry.Heads - 1;
408  Int13Drives[i].NumberDrives = DiskCount;
409 
410  TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
411  DriveNumber,
412  Geometry.Cylinders - 1,
413  Geometry.Heads - 1,
414  Geometry.Sectors,
415  Geometry.BytesPerSector);
416  }
417  }
418 
419  /* Update the 'System' key's configuration data with BIOS INT13h information */
420  FldrSetConfigurationData(SystemKey, PartialResourceList, Size);
421 
422  /* Create and fill subkey for each harddisk */
423  for (i = 0; i < DiskCount; i++)
424  {
425  PCHAR Identifier;
426 
427  DriveNumber = 0x80 + i;
428 
429  /* Get disk values */
430  PartialResourceList = GetHarddiskConfigurationData(DriveNumber, &Size);
431  Identifier = GetHarddiskIdentifier(DriveNumber);
432 
433  /* Create disk key */
434  FldrCreateComponentKey(ControllerKey,
436  DiskPeripheral,
437  Output | Input,
438  0x0,
439  0xFFFFFFFF,
440  Identifier,
441  PartialResourceList,
442  Size,
443  &DiskKey);
444  }
445 }
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
signed char * PCHAR
Definition: retypes.h:7
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
struct _CM_INT13_DRIVE_PARAMETER CM_INT13_DRIVE_PARAMETER
GLint x0
Definition: linetemp.h:95
ULONG Cylinders
Definition: disk.h:26
Definition: arc.h:84
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369 u
UCHAR PcBiosDiskCount
Definition: hwdisk.c:44
uint32_t ULONG_PTR
Definition: typedefs.h:63
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData
Definition: hardware.c:42
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
smooth NULL
Definition: ftsmooth.c:416
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@378 DeviceSpecificData
void * PVOID
Definition: retypes.h:9
#define MachDiskGetDriveGeometry(Drive, Geom)
Definition: machine.h:122
ULONG Sectors
Definition: disk.h:28
#define TRACE(s)
Definition: solgame.cpp:4
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
PCHAR GetHarddiskIdentifier(UCHAR DriveNumber)
Definition: hwdisk.c:203
static PCONFIGURATION_COMPONENT_DATA DetectBiosFloppyController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: hardware.c:280
unsigned char UCHAR
Definition: xmlstorage.h:181
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
Definition: arc.h:85
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
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
#define ERR(fmt,...)
Definition: debug.h:109
ULONG BytesPerSector
Definition: disk.h:29
unsigned short USHORT
Definition: pedump.c:61
Definition: disk.h:24
unsigned int ULONG
Definition: retypes.h:1
#define memset(x, y, z)
Definition: compat.h:39
VOID NTAPI FldrSetConfigurationData(IN PCONFIGURATION_COMPONENT_DATA ComponentData, IN PCM_PARTIAL_RESOURCE_LIST ResourceList, IN ULONG Size)
Definition: archwsup.c:78
#define TAG_HW_RESOURCE_LIST
Definition: hardware.h:26
ULONG Heads
Definition: disk.h:27

Referenced by DetectIsaBios().

◆ DetectBiosFloppyController()

static PCONFIGURATION_COMPONENT_DATA DetectBiosFloppyController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 280 of file hardware.c.

281 {
282  PCONFIGURATION_COMPONENT_DATA ControllerKey;
283  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
284  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
285  ULONG Size;
286  ULONG FloppyCount;
287 
288  FloppyCount = GetFloppyCount();
289  TRACE("Floppy count: %u\n", FloppyCount);
290 
291  /* Always create a BIOS disk controller, no matter if we have floppy drives or not */
292  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
293  2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
294  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
295  if (PartialResourceList == NULL)
296  {
297  ERR("Failed to allocate resource descriptor\n");
298  return NULL;
299  }
300  memset(PartialResourceList, 0, Size);
301 
302  /* Initialize resource descriptor */
303  PartialResourceList->Version = 1;
304  PartialResourceList->Revision = 1;
305  PartialResourceList->Count = 3;
306 
307  /* Set IO Port */
308  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
309  PartialDescriptor->Type = CmResourceTypePort;
311  PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
312  PartialDescriptor->u.Port.Start.LowPart = 0x03F0;
313  PartialDescriptor->u.Port.Start.HighPart = 0x0;
314  PartialDescriptor->u.Port.Length = 8;
315 
316  /* Set Interrupt */
317  PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
318  PartialDescriptor->Type = CmResourceTypeInterrupt;
319  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
320  PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
321  PartialDescriptor->u.Interrupt.Level = 6;
322  PartialDescriptor->u.Interrupt.Vector = 6;
323  PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
324 
325  /* Set DMA channel */
326  PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
327  PartialDescriptor->Type = CmResourceTypeDma;
328  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
329  PartialDescriptor->Flags = 0;
330  PartialDescriptor->u.Dma.Channel = 2;
331  PartialDescriptor->u.Dma.Port = 0;
332 
333  /* Create floppy disk controller */
334  FldrCreateComponentKey(BusKey,
337  Output | Input,
338  0x0,
339  0xFFFFFFFF,
340  NULL,
341  PartialResourceList,
342  Size,
343  &ControllerKey);
344  TRACE("Created key: DiskController\\0\n");
345 
346  if (FloppyCount)
347  DetectBiosFloppyPeripheral(ControllerKey);
348 
349  return ControllerKey;
350 }
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
GLint x0
Definition: linetemp.h:95
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@371 Port
Definition: arc.h:84
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@375 Dma
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@372 Interrupt
#define CmResourceTypePort
Definition: hwresource.cpp:123
smooth NULL
Definition: ftsmooth.c:416
static VOID DetectBiosFloppyPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: hardware.c:209
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
#define TRACE(s)
Definition: solgame.cpp:4
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
Definition: arc.h:85
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
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
#define ERR(fmt,...)
Definition: debug.h:109
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
static UCHAR GetFloppyCount(VOID)
Definition: hardware.c:170
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
unsigned int ULONG
Definition: retypes.h:1
#define memset(x, y, z)
Definition: compat.h:39
#define TAG_HW_RESOURCE_LIST
Definition: hardware.h:26
#define CmResourceTypeDma
Definition: hwresource.cpp:126

Referenced by DetectBiosDisks().

◆ DetectBiosFloppyPeripheral()

static VOID DetectBiosFloppyPeripheral ( PCONFIGURATION_COMPONENT_DATA  ControllerKey)
static

Definition at line 209 of file hardware.c.

210 {
211  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
212  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
213  PCM_FLOPPY_DEVICE_DATA FloppyData;
214  CHAR Identifier[20];
215  PCONFIGURATION_COMPONENT_DATA PeripheralKey;
216  ULONG Size;
217  UCHAR FloppyNumber;
218  UCHAR FloppyType;
219  ULONG MaxDensity[6] = {0, 360, 1200, 720, 1440, 2880};
220  PUCHAR Ptr;
221 
222  for (FloppyNumber = 0; FloppyNumber < 2; FloppyNumber++)
223  {
224  FloppyType = GetFloppyType(FloppyNumber);
225 
226  if ((FloppyType > 5) || (FloppyType == 0))
227  continue;
228 
229  if (!DiskResetController(FloppyNumber))
230  continue;
231 
232  Ptr = GetInt1eTable();
233 
234  /* Set 'Identifier' value */
235  sprintf(Identifier, "FLOPPY%d", FloppyNumber + 1);
236 
237  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
238  sizeof(CM_FLOPPY_DEVICE_DATA);
239  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
240  if (PartialResourceList == NULL)
241  {
242  ERR("Failed to allocate resource descriptor\n");
243  return;
244  }
245 
246  memset(PartialResourceList, 0, Size);
247  PartialResourceList->Version = 1;
248  PartialResourceList->Revision = 1;
249  PartialResourceList->Count = 1;
250 
251  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
252  PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
253  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
254  PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_FLOPPY_DEVICE_DATA);
255 
256  FloppyData = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
257  FloppyData->Version = 2;
258  FloppyData->Revision = 0;
259  FloppyData->MaxDensity = MaxDensity[FloppyType];
260  FloppyData->MountDensity = 0;
261  RtlCopyMemory(&FloppyData->StepRateHeadUnloadTime, Ptr, 11);
262  FloppyData->MaximumTrackValue = (FloppyType == 1) ? 39 : 79;
263  FloppyData->DataTransferRate = 0;
264 
265  FldrCreateComponentKey(ControllerKey,
267  FloppyDiskPeripheral,
268  Input | Output,
269  FloppyNumber,
270  0xFFFFFFFF,
271  Identifier,
272  PartialResourceList,
273  Size,
274  &PeripheralKey);
275  }
276 }
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
BOOLEAN DiskResetController(UCHAR DriveNumber)
Definition: pcdisk.c:79
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
unsigned char * PUCHAR
Definition: retypes.h:3
char CHAR
Definition: xmlstorage.h:175
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Definition: arc.h:84
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369 u
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define sprintf(buf, format,...)
Definition: sprintf.c:55
smooth NULL
Definition: ftsmooth.c:416
static PVOID GetInt1eTable(VOID)
Definition: hardware.c:199
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@369::@378 DeviceSpecificData
void * PVOID
Definition: retypes.h:9
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
static UCHAR GetFloppyType(UCHAR DriveNumber)
Definition: hardware.c:182
unsigned char UCHAR
Definition: xmlstorage.h:181
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
Definition: arc.h:85
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
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
#define ERR(fmt,...)
Definition: debug.h:109
UCHAR StepRateHeadUnloadTime
Definition: cmtypes.h:487
struct _CM_FLOPPY_DEVICE_DATA CM_FLOPPY_DEVICE_DATA
unsigned int ULONG
Definition: retypes.h:1
#define memset(x, y, z)
Definition: compat.h:39
#define TAG_HW_RESOURCE_LIST
Definition: hardware.h:26

Referenced by DetectBiosFloppyController().

◆ FrLdrCheckCpuCompatibility()

VOID FrLdrCheckCpuCompatibility ( VOID  )

Definition at line 448 of file hardware.c.

449 {
450  INT CpuInformation[4] = {-1};
451  ULONG NumberOfIds;
452 
453  /* Check if the processor first supports ID 1 */
454  __cpuid(CpuInformation, 0);
455 
456  NumberOfIds = CpuInformation[0];
457 
458  if (NumberOfIds == 0)
459  {
461  __FILE__,
462  __LINE__,
463  "ReactOS requires the CPUID instruction to return "
464  "more than one supported ID.\n\n");
465  }
466 
467  /* NumberOfIds will be greater than 1 if the processor is new enough */
468  if (NumberOfIds == 1)
469  {
470  INT ProcessorFamily;
471 
472  /* Get information */
473  __cpuid(CpuInformation, 1);
474 
475  ProcessorFamily = (CpuInformation[0] >> 8) & 0xF;
476 
477  /* If it's Family 4 or lower, bugcheck */
478  if (ProcessorFamily < 5)
479  {
481  __FILE__,
482  __LINE__,
483  "Processor is too old (family %u < 5)\n"
484  "ReactOS requires a Pentium-level processor or newer.",
485  ProcessorFamily);
486  }
487  }
488 }
int32_t INT
Definition: typedefs.h:56
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
Definition: intrin_ppc.h:682
VOID FrLdrBugCheckWithMessage(ULONG BugCode, PCHAR File, ULONG Line, PSTR Format,...)
Definition: entry.c:23
unsigned int ULONG
Definition: retypes.h:1

◆ GetFloppyCount()

static UCHAR GetFloppyCount ( VOID  )
static

Definition at line 170 of file hardware.c.

171 {
172  UCHAR Data;
173 
174  WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
175  Data = READ_PORT_UCHAR((PUCHAR)0x71);
176 
177  return ((Data & 0xF0) ? 1 : 0) + ((Data & 0x0F) ? 1 : 0);
178 }
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
unsigned char UCHAR
Definition: xmlstorage.h:181
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539

Referenced by DetectBiosFloppyController().

◆ GetFloppyType()

static UCHAR GetFloppyType ( UCHAR  DriveNumber)
static

Definition at line 182 of file hardware.c.

183 {
184  UCHAR Data;
185 
186  WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
187  Data = READ_PORT_UCHAR((PUCHAR)0x71);
188 
189  if (DriveNumber == 0)
190  return Data >> 4;
191  else if (DriveNumber == 1)
192  return Data & 0x0F;
193 
194  return 0;
195 }
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
unsigned char UCHAR
Definition: xmlstorage.h:181
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539

Referenced by DetectBiosFloppyPeripheral().

◆ GetHarddiskIdentifier()

PCHAR GetHarddiskIdentifier ( UCHAR  DriveNumber)

Definition at line 203 of file hwdisk.c.

204 {
205  return PcDiskIdentifier[DriveNumber - 0x80];
206 }
static CHAR PcDiskIdentifier[32][20]
Definition: hwdisk.c:45

Referenced by DetectBiosDisks().

◆ GetInt1eTable()

static PVOID GetInt1eTable ( VOID  )
static

Definition at line 199 of file hardware.c.

200 {
201  PUSHORT SegPtr = (PUSHORT)0x7A;
202  PUSHORT OfsPtr = (PUSHORT)0x78;
203 
204  return (PVOID)((ULONG_PTR)(((ULONG)(*SegPtr)) << 4) + (ULONG)(*OfsPtr));
205 }
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
unsigned short * PUSHORT
Definition: retypes.h:2

Referenced by DetectBiosFloppyPeripheral().

◆ HalpCalibrateStallExecution()

VOID HalpCalibrateStallExecution ( VOID  )

Definition at line 102 of file hardware.c.

103 {
104  ULONG i;
105  ULONG calib_bit;
106  ULONG CurCount;
107 
108  /* Initialise timer interrupt with MILLISECOND ms interval */
109  WRITE_PORT_UCHAR((PUCHAR)0x43, 0x34); /* binary, mode 2, LSB/MSB, ch 0 */
110  WRITE_PORT_UCHAR((PUCHAR)0x40, LATCH & 0xff); /* LSB */
111  WRITE_PORT_UCHAR((PUCHAR)0x40, LATCH >> 8); /* MSB */
112 
113  /* Stage 1: Coarse calibration */
114 
115  delay_count = 1;
116 
117  do
118  {
119  /* Next delay count to try */
120  delay_count <<= 1;
121 
123 
124  /* Do the delay */
126 
127  CurCount = Read8254Timer();
128  }
129  while (CurCount > LATCH / 2);
130 
131  /* Get bottom value for delay */
132  delay_count >>= 1;
133 
134  /* Stage 2: Fine calibration */
135 
136  /* Which bit are we going to test */
137  calib_bit = delay_count;
138 
139  for (i = 0; i < PRECISION; i++)
140  {
141  /* Next bit to calibrate */
142  calib_bit >>= 1;
143 
144  /* If we have done all bits, stop */
145  if (!calib_bit) break;
146 
147  /* Set the bit in delay_count */
148  delay_count |= calib_bit;
149 
151 
152  /* Do the delay */
154 
155  CurCount = Read8254Timer();
156  /* If a tick has passed, turn the calibrated bit back off */
157  if (CurCount <= LATCH / 2)
158  delay_count &= ~calib_bit;
159  }
160 
161  /* We're finished: Do the finishing touches */
162 
163  /* Calculate delay_count for 1ms */
164  delay_count /= (MILLISEC / 2);
165 }
static VOID __StallExecutionProcessor(ULONG Loops)
Definition: hardware.c:51
unsigned char * PUCHAR
Definition: retypes.h:3
static VOID WaitFor8254Wraparound(VOID)
Definition: hardware.c:78
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 PRECISION
Definition: hardware.c:30
#define MILLISEC
Definition: hardware.c:29
static unsigned int delay_count
Definition: hardware.c:36
static ULONG Read8254Timer(VOID)
Definition: hardware.c:65
#define LATCH
Definition: hardware.c:34
unsigned int ULONG
Definition: retypes.h:1
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539

Referenced by HalInitSystem(), and MachInit().

◆ Read8254Timer()

static ULONG Read8254Timer ( VOID  )
static

Definition at line 65 of file hardware.c.

66 {
67  ULONG Count;
68 
69  WRITE_PORT_UCHAR((PUCHAR)0x43, 0x00);
70  Count = READ_PORT_UCHAR((PUCHAR)0x40);
71  Count |= READ_PORT_UCHAR((PUCHAR)0x40) << 8;
72 
73  return Count;
74 }
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
unsigned int ULONG
Definition: retypes.h:1
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539

Referenced by HalpCalibrateStallExecution(), and WaitFor8254Wraparound().

◆ StallExecutionProcessor()

VOID StallExecutionProcessor ( ULONG  Microseconds)

Definition at line 57 of file hardware.c.

58 {
59  ULONGLONG LoopCount = ((ULONGLONG)delay_count * (ULONGLONG)Microseconds) / 1000ULL;
60  __StallExecutionProcessor((ULONG)LoopCount);
61 }
static VOID __StallExecutionProcessor(ULONG Loops)
Definition: hardware.c:51
#define ULL(a, b)
Definition: format_msg.c:27
uint64_t ULONGLONG
Definition: typedefs.h:65
static unsigned int delay_count
Definition: hardware.c:36
unsigned int ULONG
Definition: retypes.h:1

Referenced by DetectKeyboardDevice(), DetectPS2AuxDevice(), DetectPS2AuxPort(), DetectSerialMouse(), GetSerialMousePnpId(), PS2ControllerWait(), WinLdrInitializeHeadlessPort(), WriteToSMBus(), and XboxDiskPolledRead().

◆ WaitFor8254Wraparound()

static VOID WaitFor8254Wraparound ( VOID  )
static

Definition at line 78 of file hardware.c.

79 {
80  ULONG CurCount;
81  ULONG PrevCount = ~0;
82  LONG Delta;
83 
84  CurCount = Read8254Timer();
85 
86  do
87  {
88  PrevCount = CurCount;
89  CurCount = Read8254Timer();
90  Delta = CurCount - PrevCount;
91 
92  /*
93  * This limit for delta seems arbitrary, but it isn't, it's
94  * slightly above the level of error a buggy Mercury/Neptune
95  * chipset timer can cause.
96  */
97  }
98  while (Delta < 300);
99 }
long LONG
Definition: pedump.c:60
static ULONG Delta
Definition: xboxvideo.c:28
static ULONG Read8254Timer(VOID)
Definition: hardware.c:65
unsigned int ULONG
Definition: retypes.h:1

Referenced by HalpCalibrateStallExecution().

Variable Documentation

◆ delay_count

unsigned int delay_count = 1
static

Definition at line 36 of file hardware.c.

Referenced by HalpCalibrateStallExecution(), and StallExecutionProcessor().

◆ GetHarddiskConfigurationData

GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData = NULL

Definition at line 42 of file hardware.c.

Referenced by DetectBiosDisks(), PcHwDetect(), and XboxHwDetect().

◆ PcBiosDiskCount

UCHAR PcBiosDiskCount

Definition at line 44 of file hwdisk.c.

Referenced by DetectBiosDisks(), and EnumerateHarddisks().