ReactOS  0.4.15-dev-5455-g015cd25
pchw.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for pchw.c:

Go to the source code of this file.

Macros

#define MILLISEC   (10)
 
#define PRECISION   (8)
 
#define CLOCK_TICK_RATE   1193182
 
#define HZ   (100)
 
#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 33 of file pchw.c.

◆ HZ

#define HZ   (100)

Definition at line 36 of file pchw.c.

◆ LATCH

#define LATCH   (CLOCK_TICK_RATE / HZ)

Definition at line 37 of file pchw.c.

◆ MILLISEC

#define MILLISEC   (10)

Definition at line 27 of file pchw.c.

◆ PRECISION

#define PRECISION   (8)

Definition at line 28 of file pchw.c.

Function Documentation

◆ __StallExecutionProcessor()

static VOID __StallExecutionProcessor ( ULONG  Loops)
static

Definition at line 54 of file pchw.c.

55 {
56  register volatile unsigned int i;
57  for (i = 0; i < Loops; i++);
58 }
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 345 of file pchw.c.

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

Referenced by DetectIsaBios().

◆ DetectBiosFloppyController()

static PCONFIGURATION_COMPONENT_DATA DetectBiosFloppyController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 272 of file pchw.c.

273 {
274  PCONFIGURATION_COMPONENT_DATA ControllerKey;
275  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
276  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
277  ULONG Size;
278  ULONG FloppyCount;
279 
280  FloppyCount = MachGetFloppyCount();
281  TRACE("Floppy count: %u\n", FloppyCount);
282 
283  /* Always create a BIOS disk controller, no matter if we have floppy drives or not */
284  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
285  2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
286  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
287  if (PartialResourceList == NULL)
288  {
289  ERR("Failed to allocate resource descriptor\n");
290  return NULL;
291  }
292 
293  /* Initialize resource descriptor */
294  RtlZeroMemory(PartialResourceList, Size);
295  PartialResourceList->Version = 1;
296  PartialResourceList->Revision = 1;
297  PartialResourceList->Count = 3;
298 
299  /* Set IO Port */
300  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
301  PartialDescriptor->Type = CmResourceTypePort;
303  PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
304  PartialDescriptor->u.Port.Start.LowPart = 0x03F0;
305  PartialDescriptor->u.Port.Start.HighPart = 0x0;
306  PartialDescriptor->u.Port.Length = 8;
307 
308  /* Set Interrupt */
309  PartialDescriptor = &PartialResourceList->PartialDescriptors[1];
310  PartialDescriptor->Type = CmResourceTypeInterrupt;
311  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
312  PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
313  PartialDescriptor->u.Interrupt.Level = 6;
314  PartialDescriptor->u.Interrupt.Vector = 6;
315  PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
316 
317  /* Set DMA channel */
318  PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
319  PartialDescriptor->Type = CmResourceTypeDma;
320  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
321  PartialDescriptor->Flags = 0;
322  PartialDescriptor->u.Dma.Channel = 2;
323  PartialDescriptor->u.Dma.Port = 0;
324 
325  /* Create floppy disk controller */
326  FldrCreateComponentKey(BusKey,
329  Output | Input,
330  0x0,
331  0xFFFFFFFF,
332  NULL,
333  PartialResourceList,
334  Size,
335  &ControllerKey);
336  TRACE("Created key: DiskController\\0\n");
337 
338  if (FloppyCount)
339  DetectBiosFloppyPeripheral(ControllerKey);
340 
341  return ControllerKey;
342 }
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
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381::@383 Port
#define CmResourceTypePort
Definition: hwresource.cpp:123
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381::@387 Dma
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:174
#define TRACE(s)
Definition: solgame.cpp:4
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
Definition: arc.h:85
static VOID DetectBiosFloppyPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: pchw.c:200
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:110
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define NULL
Definition: types.h:112
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381::@384 Interrupt
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381 u
#define TAG_HW_RESOURCE_LIST
Definition: hardware.h:23
#define CmResourceTypeDma
Definition: hwresource.cpp:126

Referenced by DetectBiosDisks().

◆ DetectBiosFloppyPeripheral()

static VOID DetectBiosFloppyPeripheral ( PCONFIGURATION_COMPONENT_DATA  ControllerKey)
static

Definition at line 200 of file pchw.c.

201 {
202  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
203  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
204  PCM_FLOPPY_DEVICE_DATA FloppyData;
205  CHAR Identifier[20];
206  PCONFIGURATION_COMPONENT_DATA PeripheralKey;
207  ULONG Size;
208  UCHAR FloppyNumber;
209  UCHAR FloppyType;
210  ULONG MaxDensity[6] = {0, 360, 1200, 720, 1440, 2880};
211  PUCHAR Ptr;
212 
213  for (FloppyNumber = 0; FloppyNumber < 2; FloppyNumber++)
214  {
215  FloppyType = GetFloppyType(FloppyNumber);
216 
217  if ((FloppyType > 5) || (FloppyType == 0))
218  continue;
219 
220  if (!DiskResetController(FloppyNumber))
221  continue;
222 
223  Ptr = GetInt1eTable();
224 
225  /* Set 'Identifier' value */
226  sprintf(Identifier, "FLOPPY%d", FloppyNumber + 1);
227 
228  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
229  sizeof(CM_FLOPPY_DEVICE_DATA);
230  PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
231  if (PartialResourceList == NULL)
232  {
233  ERR("Failed to allocate resource descriptor! Ignoring remaining floppy peripherals. (FloppyNumber = %u)\n",
234  FloppyNumber);
235  return;
236  }
237 
238  RtlZeroMemory(PartialResourceList, Size);
239  PartialResourceList->Version = 1;
240  PartialResourceList->Revision = 1;
241  PartialResourceList->Count = 1;
242 
243  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
244  PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
245  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
246  PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_FLOPPY_DEVICE_DATA);
247 
248  FloppyData = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
249  FloppyData->Version = 2;
250  FloppyData->Revision = 0;
251  FloppyData->MaxDensity = MaxDensity[FloppyType];
252  FloppyData->MountDensity = 0;
253  RtlCopyMemory(&FloppyData->StepRateHeadUnloadTime, Ptr, 11);
254  FloppyData->MaximumTrackValue = (FloppyType == 1) ? 39 : 79;
255  FloppyData->DataTransferRate = 0;
256 
257  FldrCreateComponentKey(ControllerKey,
259  FloppyDiskPeripheral,
260  Input | Output,
261  FloppyNumber,
262  0xFFFFFFFF,
263  Identifier,
264  PartialResourceList,
265  Size,
266  &PeripheralKey);
267  }
268 }
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
BOOLEAN DiskResetController(UCHAR DriveNumber)
Definition: pcdisk.c:180
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
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
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381::@390 DeviceSpecificData
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define sprintf(buf, format,...)
Definition: sprintf.c:55
void * PVOID
Definition: retypes.h:9
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:174
unsigned char UCHAR
Definition: xmlstorage.h:181
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
Definition: arc.h:85
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:110
UCHAR StepRateHeadUnloadTime
Definition: cmtypes.h:489
struct _CM_FLOPPY_DEVICE_DATA CM_FLOPPY_DEVICE_DATA
static UCHAR GetFloppyType(UCHAR DriveNumber)
Definition: pchw.c:173
static PVOID GetInt1eTable(VOID)
Definition: pchw.c:190
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@381 u
#define TAG_HW_RESOURCE_LIST
Definition: hardware.h:23

Referenced by DetectBiosFloppyController().

◆ FrLdrCheckCpuCompatibility()

VOID FrLdrCheckCpuCompatibility ( VOID  )

Definition at line 440 of file pchw.c.

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

174 {
175  UCHAR Data;
176 
177  WRITE_PORT_UCHAR((PUCHAR)0x70, 0x10);
178  Data = READ_PORT_UCHAR((PUCHAR)0x71);
179 
180  if (DriveNumber == 0)
181  return Data >> 4;
182  else if (DriveNumber == 1)
183  return Data & 0x0F;
184 
185  return 0;
186 }
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
unsigned char UCHAR
Definition: xmlstorage.h:181
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21

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 190 of file pchw.c.

191 {
192  PUSHORT SegPtr = (PUSHORT)0x7A;
193  PUSHORT OfsPtr = (PUSHORT)0x78;
194 
195  return (PVOID)((ULONG_PTR)(((ULONG)(*SegPtr)) << 4) + (ULONG)(*OfsPtr));
196 }
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 105 of file pchw.c.

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

Referenced by HalInitSystem(), and MachInit().

◆ Read8254Timer()

static ULONG Read8254Timer ( VOID  )
static

Definition at line 68 of file pchw.c.

69 {
70  ULONG Count;
71 
72  WRITE_PORT_UCHAR((PUCHAR)0x43, 0x00);
73  Count = READ_PORT_UCHAR((PUCHAR)0x40);
74  Count |= READ_PORT_UCHAR((PUCHAR)0x40) << 8;
75 
76  return Count;
77 }
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
unsigned char * PUCHAR
Definition: retypes.h:3
int Count
Definition: noreturn.cpp:7
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
unsigned int ULONG
Definition: retypes.h:1

Referenced by HalpCalibrateStallExecution(), and WaitFor8254Wraparound().

◆ StallExecutionProcessor()

VOID StallExecutionProcessor ( ULONG  Microseconds)

◆ WaitFor8254Wraparound()

static VOID WaitFor8254Wraparound ( VOID  )
static

Definition at line 81 of file pchw.c.

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

Referenced by HalpCalibrateStallExecution().

Variable Documentation

◆ delay_count

unsigned int delay_count = 1
static

Definition at line 39 of file pchw.c.

Referenced by HalpCalibrateStallExecution(), and StallExecutionProcessor().

◆ GetHarddiskConfigurationData

GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData = NULL

Definition at line 45 of file pchw.c.

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

◆ PcBiosDiskCount

UCHAR PcBiosDiskCount

Definition at line 43 of file hwdisk.c.

Referenced by DetectBiosDisks().