ReactOS  0.4.14-dev-554-g2f8d847
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 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 31 of file hardware.c.

◆ HZ

#define HZ   (100)

Definition at line 30 of file hardware.c.

◆ LATCH

#define LATCH   (CLOCK_TICK_RATE / HZ)

Definition at line 32 of file hardware.c.

◆ MILLISEC

#define MILLISEC   (10)

Definition at line 27 of file hardware.c.

◆ PRECISION

#define PRECISION   (8)

Definition at line 28 of file hardware.c.

Function Documentation

◆ __StallExecutionProcessor()

static VOID __StallExecutionProcessor ( ULONG  Loops)
static

Definition at line 49 of file hardware.c.

50 {
51  register volatile unsigned int i;
52  for (i = 0; i < Loops; i++);
53 }
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 339 of file hardware.c.

341 {
342  PCONFIGURATION_COMPONENT_DATA ControllerKey, DiskKey;
343  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
344  PCM_INT13_DRIVE_PARAMETER Int13Drives;
345  GEOMETRY Geometry;
346  UCHAR DiskCount, DriveNumber;
347  USHORT i;
348  ULONG Size;
349 
350  /* The pre-enumeration of the BIOS disks was already done in InitializeBootDevices() */
351  DiskCount = PcBiosDiskCount;
352 
353  /* Use the floppy disk controller as our controller */
354  ControllerKey = DetectBiosFloppyController(BusKey);
355  if (!ControllerKey)
356  {
357  ERR("Failed to detect BIOS disk controller\n");
358  return;
359  }
360 
361  /* Allocate resource descriptor */
362  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
363  sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
364  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
365  if (PartialResourceList == NULL)
366  {
367  ERR("Failed to allocate resource descriptor\n");
368  return;
369  }
370 
371  /* Initialize resource descriptor */
372  memset(PartialResourceList, 0, Size);
373  PartialResourceList->Version = 1;
374  PartialResourceList->Revision = 1;
375  PartialResourceList->Count = 1;
376  PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeDeviceSpecific;
377  PartialResourceList->PartialDescriptors[0].ShareDisposition = 0;
378  PartialResourceList->PartialDescriptors[0].Flags = 0;
379  PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
380  sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
381 
382  /* Get harddisk Int13 geometry data */
383  Int13Drives = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
384  for (i = 0; i < DiskCount; i++)
385  {
386  DriveNumber = 0x80 + i;
387 
388  if (MachDiskGetDriveGeometry(DriveNumber, &Geometry))
389  {
390  Int13Drives[i].DriveSelect = DriveNumber;
391  Int13Drives[i].MaxCylinders = Geometry.Cylinders - 1;
392  Int13Drives[i].SectorsPerTrack = (USHORT)Geometry.Sectors;
393  Int13Drives[i].MaxHeads = (USHORT)Geometry.Heads - 1;
394  Int13Drives[i].NumberDrives = DiskCount;
395 
396  TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
397  DriveNumber,
398  Geometry.Cylinders - 1,
399  Geometry.Heads - 1,
400  Geometry.Sectors,
401  Geometry.BytesPerSector);
402  }
403  }
404 
405  /* Update the 'System' key's configuration data with BIOS INT13h information */
406  FldrSetConfigurationData(SystemKey, PartialResourceList, Size);
407 
408  /* Create and fill subkey for each harddisk */
409  for (i = 0; i < DiskCount; i++)
410  {
411  PCHAR Identifier;
412 
413  DriveNumber = 0x80 + i;
414 
415  /* Get disk values */
416  PartialResourceList = GetHarddiskConfigurationData(DriveNumber, &Size);
417  Identifier = GetHarddiskIdentifier(DriveNumber);
418 
419  /* Create disk key */
420  FldrCreateComponentKey(ControllerKey,
422  DiskPeripheral,
423  Output | Input,
424  0x0,
425  0xFFFFFFFF,
426  Identifier,
427  PartialResourceList,
428  Size,
429  &DiskKey);
430  }
431 }
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
UCHAR PcBiosDiskCount
Definition: hwdisk.c:43
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376::@385 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376 u
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData
Definition: hardware.c:40
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
void * PVOID
Definition: retypes.h:9
#define MachDiskGetDriveGeometry(Drive, Geom)
Definition: machine.h:128
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:249
static PCONFIGURATION_COMPONENT_DATA DetectBiosFloppyController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: hardware.c:266
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 266 of file hardware.c.

267 {
268  PCONFIGURATION_COMPONENT_DATA ControllerKey;
269  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
270  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
271  ULONG Size;
272  ULONG FloppyCount;
273 
274  FloppyCount = MachGetFloppyCount();
275  TRACE("Floppy count: %u\n", FloppyCount);
276 
277  /* Always create a BIOS disk controller, no matter if we have floppy drives or not */
278  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
279  2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
280  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
281  if (PartialResourceList == NULL)
282  {
283  ERR("Failed to allocate resource descriptor\n");
284  return NULL;
285  }
286  memset(PartialResourceList, 0, Size);
287 
288  /* Initialize resource descriptor */
289  PartialResourceList->Version = 1;
290  PartialResourceList->Revision = 1;
291  PartialResourceList->Count = 3;
292 
293  /* Set IO Port */
294  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
295  PartialDescriptor->Type = CmResourceTypePort;
297  PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
298  PartialDescriptor->u.Port.Start.LowPart = 0x03F0;
299  PartialDescriptor->u.Port.Start.HighPart = 0x0;
300  PartialDescriptor->u.Port.Length = 8;
301 
302  /* Set Interrupt */
303  PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
304  PartialDescriptor->Type = CmResourceTypeInterrupt;
305  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
306  PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
307  PartialDescriptor->u.Interrupt.Level = 6;
308  PartialDescriptor->u.Interrupt.Vector = 6;
309  PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
310 
311  /* Set DMA channel */
312  PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
313  PartialDescriptor->Type = CmResourceTypeDma;
314  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
315  PartialDescriptor->Flags = 0;
316  PartialDescriptor->u.Dma.Channel = 2;
317  PartialDescriptor->u.Dma.Port = 0;
318 
319  /* Create floppy disk controller */
320  FldrCreateComponentKey(BusKey,
323  Output | Input,
324  0x0,
325  0xFFFFFFFF,
326  NULL,
327  PartialResourceList,
328  Size,
329  &ControllerKey);
330  TRACE("Created key: DiskController\\0\n");
331 
332  if (FloppyCount)
333  DetectBiosFloppyPeripheral(ControllerKey);
334 
335  return ControllerKey;
336 }
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
GLint x0
Definition: linetemp.h:95
Definition: arc.h:84
#define MachGetFloppyCount()
Definition: machine.h:124
#define CmResourceTypePort
Definition: hwresource.cpp:123
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376::@382 Dma
smooth NULL
Definition: ftsmooth.c:416
static VOID DetectBiosFloppyPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: hardware.c:195
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
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376::@378 Port
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
unsigned int ULONG
Definition: retypes.h:1
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376::@379 Interrupt
#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 195 of file hardware.c.

196 {
197  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
198  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
199  PCM_FLOPPY_DEVICE_DATA FloppyData;
200  CHAR Identifier[20];
201  PCONFIGURATION_COMPONENT_DATA PeripheralKey;
202  ULONG Size;
203  UCHAR FloppyNumber;
204  UCHAR FloppyType;
205  ULONG MaxDensity[6] = {0, 360, 1200, 720, 1440, 2880};
206  PUCHAR Ptr;
207 
208  for (FloppyNumber = 0; FloppyNumber < 2; FloppyNumber++)
209  {
210  FloppyType = GetFloppyType(FloppyNumber);
211 
212  if ((FloppyType > 5) || (FloppyType == 0))
213  continue;
214 
215  if (!DiskResetController(FloppyNumber))
216  continue;
217 
218  Ptr = GetInt1eTable();
219 
220  /* Set 'Identifier' value */
221  sprintf(Identifier, "FLOPPY%d", FloppyNumber + 1);
222 
223  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
224  sizeof(CM_FLOPPY_DEVICE_DATA);
225  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
226  if (PartialResourceList == NULL)
227  {
228  ERR("Failed to allocate resource descriptor\n");
229  return;
230  }
231 
232  memset(PartialResourceList, 0, Size);
233  PartialResourceList->Version = 1;
234  PartialResourceList->Revision = 1;
235  PartialResourceList->Count = 1;
236 
237  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
238  PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
239  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
240  PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_FLOPPY_DEVICE_DATA);
241 
242  FloppyData = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
243  FloppyData->Version = 2;
244  FloppyData->Revision = 0;
245  FloppyData->MaxDensity = MaxDensity[FloppyType];
246  FloppyData->MountDensity = 0;
247  RtlCopyMemory(&FloppyData->StepRateHeadUnloadTime, Ptr, 11);
248  FloppyData->MaximumTrackValue = (FloppyType == 1) ? 39 : 79;
249  FloppyData->DataTransferRate = 0;
250 
251  FldrCreateComponentKey(ControllerKey,
253  FloppyDiskPeripheral,
254  Input | Output,
255  FloppyNumber,
256  0xFFFFFFFF,
257  Identifier,
258  PartialResourceList,
259  Size,
260  &PeripheralKey);
261  }
262 }
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
BOOLEAN DiskResetController(UCHAR DriveNumber)
Definition: pcdisk.c:140
#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
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376::@385 DeviceSpecificData
#define sprintf(buf, format,...)
Definition: sprintf.c:55
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@376 u
smooth NULL
Definition: ftsmooth.c:416
static PVOID GetInt1eTable(VOID)
Definition: hardware.c:185
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:168
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 434 of file hardware.c.

435 {
436  INT CpuInformation[4] = {-1};
437  ULONG NumberOfIds;
438 
439  /* Check if the processor first supports ID 1 */
440  __cpuid(CpuInformation, 0);
441 
442  NumberOfIds = CpuInformation[0];
443 
444  if (NumberOfIds == 0)
445  {
447  __FILE__,
448  __LINE__,
449  "ReactOS requires the CPUID instruction to return "
450  "more than one supported ID.\n\n");
451  }
452 
453  /* NumberOfIds will be greater than 1 if the processor is new enough */
454  if (NumberOfIds == 1)
455  {
456  INT ProcessorFamily;
457 
458  /* Get information */
459  __cpuid(CpuInformation, 1);
460 
461  ProcessorFamily = (CpuInformation[0] >> 8) & 0xF;
462 
463  /* If it's Family 4 or lower, bugcheck */
464  if (ProcessorFamily < 5)
465  {
467  __FILE__,
468  __LINE__,
469  "Processor is too old (family %u < 5)\n"
470  "ReactOS requires a Pentium-level processor or newer.",
471  ProcessorFamily);
472  }
473  }
474 }
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

◆ GetFloppyType()

static UCHAR GetFloppyType ( UCHAR  DriveNumber)
static

Definition at line 168 of file hardware.c.

169 {
170  UCHAR Data;
171 
172  WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
173  Data = READ_PORT_UCHAR((PUCHAR)0x71);
174 
175  if (DriveNumber == 0)
176  return Data >> 4;
177  else if (DriveNumber == 1)
178  return Data & 0x0F;
179 
180  return 0;
181 }
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:528
_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:532

Referenced by DetectBiosFloppyPeripheral().

◆ GetHarddiskIdentifier()

PCHAR GetHarddiskIdentifier ( UCHAR  DriveNumber)

Definition at line 249 of file hwdisk.c.

250 {
251  return PcDiskIdentifier[DriveNumber - 0x80];
252 }
static CHAR PcDiskIdentifier[32][20]
Definition: hwdisk.c:44

Referenced by DetectBiosDisks().

◆ GetInt1eTable()

static PVOID GetInt1eTable ( VOID  )
static

Definition at line 185 of file hardware.c.

186 {
187  PUSHORT SegPtr = (PUSHORT)0x7A;
188  PUSHORT OfsPtr = (PUSHORT)0x78;
189 
190  return (PVOID)((ULONG_PTR)(((ULONG)(*SegPtr)) << 4) + (ULONG)(*OfsPtr));
191 }
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 100 of file hardware.c.

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

Referenced by HalInitSystem(), and MachInit().

◆ Read8254Timer()

static ULONG Read8254Timer ( VOID  )
static

Definition at line 63 of file hardware.c.

64 {
65  ULONG Count;
66 
67  WRITE_PORT_UCHAR((PUCHAR)0x43, 0x00);
68  Count = READ_PORT_UCHAR((PUCHAR)0x40);
69  Count |= READ_PORT_UCHAR((PUCHAR)0x40) << 8;
70 
71  return Count;
72 }
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:528
_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:532

Referenced by HalpCalibrateStallExecution(), and WaitFor8254Wraparound().

◆ StallExecutionProcessor()

VOID StallExecutionProcessor ( ULONG  Microseconds)

Definition at line 55 of file hardware.c.

56 {
57  ULONGLONG LoopCount = ((ULONGLONG)delay_count * (ULONGLONG)Microseconds) / 1000ULL;
58  __StallExecutionProcessor((ULONG)LoopCount);
59 }
static VOID __StallExecutionProcessor(ULONG Loops)
Definition: hardware.c:49
#define ULL(a, b)
Definition: format_msg.c:27
uint64_t ULONGLONG
Definition: typedefs.h:65
static unsigned int delay_count
Definition: hardware.c:34
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 76 of file hardware.c.

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

Referenced by HalpCalibrateStallExecution().

Variable Documentation

◆ delay_count

unsigned int delay_count = 1
static

Definition at line 34 of file hardware.c.

Referenced by HalpCalibrateStallExecution(), and StallExecutionProcessor().

◆ GetHarddiskConfigurationData

GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData = NULL

Definition at line 40 of file hardware.c.

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

◆ PcBiosDiskCount

UCHAR PcBiosDiskCount

Definition at line 43 of file hwdisk.c.

Referenced by DetectBiosDisks(), and EnumerateHarddisks().