ReactOS 0.4.15-dev-7201-g2de6e75
pc98hw.c File Reference
#include <freeldr.h>
#include <cportlib/cportlib.h>
#include <drivers/pc98/pit.h>
#include <drivers/pc98/fdc.h>
#include <debug.h>
Include dependency graph for pc98hw.c:

Go to the source code of this file.

Macros

#define MILLISEC   10
 
#define PRECISION   8
 
#define HZ   100
 

Functions

 DBG_DEFAULT_CHANNEL (HWDETECT)
 
PCHAR GetHarddiskIdentifier (UCHAR DriveNumber)
 
static VOID __StallExecutionProcessor (ULONG Loops)
 
VOID StallExecutionProcessor (ULONG Microseconds)
 
static VOID WaitFor8253Wraparound (VOID)
 
VOID HalpCalibrateStallExecution (VOID)
 
static UCHAR GetFloppyType (UCHAR FloppyNumber)
 
static VOID DetectBiosFloppyPeripheral (PCONFIGURATION_COMPONENT_DATA ControllerKey)
 
static PCONFIGURATION_COMPONENT_DATA DetectBiosFloppyController (PCONFIGURATION_COMPONENT_DATA BusKey)
 
static PCM_PARTIAL_RESOURCE_LIST Pc98GetHarddiskConfigurationData (UCHAR DriveNumber, ULONG *pSize)
 
VOID DetectBiosDisks (PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
 
static VOID DetectPointerPeripheral (PCONFIGURATION_COMPONENT_DATA ControllerKey)
 
static VOID DetectPointerController (PCONFIGURATION_COMPONENT_DATA BusKey)
 
static VOID DetectKeyboardPeripheral (PCONFIGURATION_COMPONENT_DATA ControllerKey)
 
static VOID DetectKeyboardController (PCONFIGURATION_COMPONENT_DATA BusKey)
 
static VOID DetectParallelPorts (PCONFIGURATION_COMPONENT_DATA BusKey)
 
static VOID DetectSerialPorts (PCONFIGURATION_COMPONENT_DATA BusKey)
 
static VOID DetectCBusBios (PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
 
static VOID DetectNesaBios (PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
 
static VOID DetectPnpBios (PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
 
PCONFIGURATION_COMPONENT_DATA Pc98HwDetect (_In_opt_ PCSTR Options)
 
UCHAR Pc98GetFloppyCount (VOID)
 
VOID __cdecl DiskStopFloppyMotor (VOID)
 
VOID FrLdrCheckCpuCompatibility (VOID)
 

Variables

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

Macro Definition Documentation

◆ HZ

#define HZ   100

Definition at line 29 of file pc98hw.c.

◆ MILLISEC

#define MILLISEC   10

Definition at line 27 of file pc98hw.c.

◆ PRECISION

#define PRECISION   8

Definition at line 28 of file pc98hw.c.

Function Documentation

◆ __StallExecutionProcessor()

static VOID __StallExecutionProcessor ( ULONG  Loops)
static

Definition at line 39 of file pc98hw.c.

40{
41 register volatile unsigned int i;
42 for (i = 0; i < Loops; i++);
43}
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 373 of file pc98hw.c.

376{
377 PCONFIGURATION_COMPONENT_DATA ControllerKey, DiskKey;
378 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
379 PCM_INT13_DRIVE_PARAMETER Int13Drives;
380 GEOMETRY Geometry;
381 UCHAR DiskCount, DriveNumber;
382 USHORT i;
383 ULONG Size;
384
385 /* The pre-enumeration of the BIOS disks was already done in InitializeBootDevices() */
386 DiskCount = PcBiosDiskCount;
387
388 /* Use the floppy disk controller as our controller */
389 ControllerKey = DetectBiosFloppyController(BusKey);
390 if (!ControllerKey)
391 {
392 ERR("Failed to detect BIOS disk controller\n");
393 return;
394 }
395
396 /* Set 'Configuration Data' value */
398 sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
399 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
400 if (PartialResourceList == NULL)
401 {
402 ERR("Failed to allocate resource descriptor\n");
403 return;
404 }
405 RtlZeroMemory(PartialResourceList, Size);
406 PartialResourceList->Version = 1;
407 PartialResourceList->Revision = 1;
408 PartialResourceList->Count = 1;
409
410 PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeDeviceSpecific;
411 PartialResourceList->PartialDescriptors[0].ShareDisposition = 0;
412 PartialResourceList->PartialDescriptors[0].Flags = 0;
413 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
414 sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
415
416 /* Get hard disk Int13 geometry data */
417 Int13Drives = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
418 for (i = 0; i < DiskCount; i++)
419 {
420 DriveNumber = 0x80 + i;
421
422 if (Pc98DiskGetDriveGeometry(DriveNumber, &Geometry))
423 {
424 Int13Drives[i].DriveSelect = DriveNumber;
425 Int13Drives[i].MaxCylinders = Geometry.Cylinders - 1;
426 Int13Drives[i].SectorsPerTrack = (USHORT)Geometry.Sectors;
427 Int13Drives[i].MaxHeads = (USHORT)Geometry.Heads - 1;
428 Int13Drives[i].NumberDrives = DiskCount;
429
430 TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
431 DriveNumber,
432 Geometry.Cylinders - 1,
433 Geometry.Heads - 1,
434 Geometry.Sectors,
435 Geometry.BytesPerSector);
436 }
437 }
438
439 /* Update the 'System' key's configuration data with BIOS INT13h information */
440 FldrSetConfigurationData(SystemKey, PartialResourceList, Size);
441
442 /* Create and fill subkey for each harddisk */
443 for (i = 0; i < DiskCount; i++)
444 {
446
447 DriveNumber = 0x80 + i;
448
449 /* Get disk values */
450 PartialResourceList = GetHarddiskConfigurationData(DriveNumber, &Size);
451 Identifier = GetHarddiskIdentifier(DriveNumber);
452
453 /* Create disk key */
454 FldrCreateComponentKey(ControllerKey,
457 Output | Input,
458 i,
459 0xFFFFFFFF,
461 PartialResourceList,
462 Size,
463 &DiskKey);
464 }
465}
VOID FldrCreateComponentKey(_In_ PCONFIGURATION_COMPONENT_DATA SystemNode, _In_ CONFIGURATION_CLASS Class, _In_ CONFIGURATION_TYPE Type, _In_ IDENTIFIER_FLAG Flags, _In_ ULONG Key, _In_ ULONG Affinity, _In_ PCSTR IdentifierString, _In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _In_ ULONG Size, _Out_ PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:198
VOID FldrSetConfigurationData(_Inout_ PCONFIGURATION_COMPONENT_DATA ComponentData, _In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _In_ ULONG Size)
Definition: archwsup.c:124
@ Identifier
Definition: asmpp.cpp:95
#define ERR(fmt,...)
Definition: debug.h:110
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:174
#define NULL
Definition: types.h:112
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
BOOLEAN Pc98DiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
Definition: pc98disk.c:870
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData
Definition: pc98hw.c:23
static PCONFIGURATION_COMPONENT_DATA DetectBiosFloppyController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pc98hw.c:227
PCHAR GetHarddiskIdentifier(UCHAR DriveNumber)
Definition: hwdisk.c:249
UCHAR PcBiosDiskCount
Definition: hwdisk.c:43
unsigned short USHORT
Definition: pedump.c:61
@ PeripheralClass
Definition: arc.h:95
@ DiskPeripheral
Definition: arc.h:129
@ Input
Definition: arc.h:84
@ Output
Definition: arc.h:85
#define TRACE(s)
Definition: solgame.cpp:4
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@383::@392 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@383 u
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
Definition: disk.h:25
ULONG BytesPerSector
Definition: disk.h:29
ULONG Sectors
Definition: disk.h:28
ULONG Cylinders
Definition: disk.h:26
ULONG Heads
Definition: disk.h:27
void * PVOID
Definition: typedefs.h:50
const char * PCSTR
Definition: typedefs.h:52
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define TAG_HW_RESOURCE_LIST
Definition: uefidisk.c:15
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
struct _CM_INT13_DRIVE_PARAMETER CM_INT13_DRIVE_PARAMETER
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DetectCBusBios().

◆ DetectBiosFloppyController()

static PCONFIGURATION_COMPONENT_DATA DetectBiosFloppyController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 227 of file pc98hw.c.

228{
229 PCONFIGURATION_COMPONENT_DATA ControllerKey;
230 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
231 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
232 ULONG Size;
233 ULONG FloppyCount;
234 UCHAR i;
235 UCHAR Index = 0;
236
237 FloppyCount = Pc98GetFloppyCount();
238
239 /* Always create a BIOS disk controller, no matter if we have floppy drives or not */
242 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
243 if (PartialResourceList == NULL)
244 {
245 ERR("Failed to allocate resource descriptor\n");
246 return NULL;
247 }
248 RtlZeroMemory(PartialResourceList, Size);
249 PartialResourceList->Version = 1;
250 PartialResourceList->Revision = 1;
251 PartialResourceList->Count = 7;
252
253 /* Set I/O ports */
254 for (i = 0; i < 3; i++)
255 {
256 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
257 PartialDescriptor->Type = CmResourceTypePort;
259 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
260 PartialDescriptor->u.Port.Start.LowPart = 0x90 + i * 2;
261 PartialDescriptor->u.Port.Start.HighPart = 0;
262 PartialDescriptor->u.Port.Length = 1;
263 }
264 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
265 PartialDescriptor->Type = CmResourceTypePort;
267 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
268 PartialDescriptor->u.Port.Start.LowPart = 0xBE;
269 PartialDescriptor->u.Port.Start.HighPart = 0;
270 PartialDescriptor->u.Port.Length = 1;
271
272 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
273 PartialDescriptor->Type = CmResourceTypePort;
275 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
276 PartialDescriptor->u.Port.Start.LowPart = 0x4BE;
277 PartialDescriptor->u.Port.Start.HighPart = 0;
278 PartialDescriptor->u.Port.Length = 1;
279
280 /* Set Interrupt */
281 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
282 PartialDescriptor->Type = CmResourceTypeInterrupt;
284 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
285 PartialDescriptor->u.Interrupt.Level = 11;
286 PartialDescriptor->u.Interrupt.Vector = 11;
287 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
288
289 /* Set DMA channel */
290 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
291 PartialDescriptor->Type = CmResourceTypeDma;
293 PartialDescriptor->Flags = 0;
294 PartialDescriptor->u.Dma.Channel = 2;
295 PartialDescriptor->u.Dma.Port = 0;
296
297 /* Create floppy disk controller */
301 Output | Input,
302 0,
303 0xFFFFFFFF,
304 NULL,
305 PartialResourceList,
306 Size,
307 &ControllerKey);
308
309 if (FloppyCount)
310 DetectBiosFloppyPeripheral(ControllerKey);
311
312 return ControllerKey;
313}
@ DiskController
Definition: arcname.c:68
#define CmResourceTypeDma
Definition: hwresource.cpp:126
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
static VOID DetectBiosFloppyPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: pc98hw.c:150
UCHAR Pc98GetFloppyCount(VOID)
Definition: pc98hw.c:1214
@ ControllerClass
Definition: arc.h:94
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@383::@386 Interrupt
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@383::@389 Dma
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@383::@385 Port
_In_ WDFCOLLECTION _In_ ULONG Index
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241
@ CmResourceShareUndetermined
Definition: cmtypes.h:240

Referenced by DetectBiosDisks().

◆ DetectBiosFloppyPeripheral()

static VOID DetectBiosFloppyPeripheral ( PCONFIGURATION_COMPONENT_DATA  ControllerKey)
static

Definition at line 150 of file pc98hw.c.

151{
152 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
153 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
154 PCM_FLOPPY_DEVICE_DATA FloppyData;
155 CHAR Identifier[20];
156 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
157 ULONG Size;
158 UCHAR FloppyNumber;
159 UCHAR FloppyType;
160 ULONG MaxDensity[6] = {0, 360, 1200, 720, 1440, 2880};
161
162 for (FloppyNumber = 0; FloppyNumber < Pc98GetFloppyCount(); FloppyNumber++)
163 {
164 FloppyType = GetFloppyType(FloppyNumber);
165
166 if ((FloppyType > 5) || (FloppyType == 0))
167 continue;
168
169 /* TODO: Properly detect */
170
171 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "FLOPPY%d", FloppyNumber + 1);
172
173 /* Set 'Configuration Data' value */
175 sizeof(CM_FLOPPY_DEVICE_DATA);
176 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
177 if (PartialResourceList == NULL)
178 {
179 ERR("Failed to allocate resource descriptor! Ignoring remaining floppy peripherals. (FloppyNumber = %u, FloppyCount = %u)\n",
180 FloppyNumber, Pc98GetFloppyCount());
181 return;
182 }
183 RtlZeroMemory(PartialResourceList, Size);
184 PartialResourceList->Version = 1;
185 PartialResourceList->Revision = 1;
186 PartialResourceList->Count = 1;
187
188 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
189 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
191 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_FLOPPY_DEVICE_DATA);
192
193 /* FIXME: Don't use default parameters for 1.44 MB floppy */
194 FloppyData = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
195 FloppyData->Version = 2;
196 FloppyData->Revision = 0;
197 FloppyData->MaxDensity = MaxDensity[FloppyType];
198 FloppyData->MountDensity = 0;
199 FloppyData->StepRateHeadUnloadTime = 175;
200 FloppyData->HeadLoadTime = 2;
201 FloppyData->MotorOffTime = 37;
202 FloppyData->SectorLengthCode = 2;
203 FloppyData->SectorPerTrack = 18;
204 FloppyData->ReadWriteGapLength = 27;
205 FloppyData->DataTransferLength = 255;
206 FloppyData->FormatGapLength = 108;
207 FloppyData->FormatFillCharacter = 0xF6;
208 FloppyData->HeadSettleTime = 15;
209 FloppyData->MotorSettleTime = 8;
210 FloppyData->MaximumTrackValue = (FloppyType == 1) ? 39 : 79;
211 FloppyData->DataTransferRate = 0;
212
213 FldrCreateComponentKey(ControllerKey,
216 Input | Output,
217 FloppyNumber,
218 0xFFFFFFFF,
220 PartialResourceList,
221 Size,
222 &PeripheralKey);
223 }
224}
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
static UCHAR GetFloppyType(UCHAR FloppyNumber)
Definition: pc98hw.c:143
@ FloppyDiskPeripheral
Definition: arc.h:130
UCHAR StepRateHeadUnloadTime
Definition: cmtypes.h:489
struct _CM_FLOPPY_DEVICE_DATA CM_FLOPPY_DEVICE_DATA
char CHAR
Definition: xmlstorage.h:175

Referenced by DetectBiosFloppyController().

◆ DetectCBusBios()

static VOID DetectCBusBios ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
ULONG BusNumber 
)
static

Definition at line 963 of file pc98hw.c.

964{
965 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
967 ULONG Size;
968
969 /* Set 'Configuration Data' value */
972 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
973 if (PartialResourceList == NULL)
974 {
975 ERR("Failed to allocate resource descriptor\n");
976 return;
977 }
978 RtlZeroMemory(PartialResourceList, Size);
979 PartialResourceList->Version = 1;
980 PartialResourceList->Revision = 1;
981 PartialResourceList->Count = 0;
982
983 /* Create bus key */
984 FldrCreateComponentKey(SystemKey,
987 0,
988 0,
989 0xFFFFFFFF,
990 "ISA",
991 PartialResourceList,
992 Size,
993 &BusKey);
994
995 /* Increment bus number */
996 (*BusNumber)++;
997
998 /* Detect C-bus/BIOS devices */
999 DetectBiosDisks(SystemKey, BusKey);
1000 DetectSerialPorts(BusKey);
1001 DetectParallelPorts(BusKey);
1004
1005 /* FIXME: Detect more C-bus devices */
1006}
static VOID DetectPointerController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pc98hw.c:504
VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pc98hw.c:373
static VOID DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pc98hw.c:654
static VOID DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pc98hw.c:800
static VOID DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
Definition: pc98hw.c:716
@ AdapterClass
Definition: arc.h:93
@ MultiFunctionAdapter
Definition: arc.h:116

Referenced by Pc98HwDetect().

◆ DetectKeyboardController()

static VOID DetectKeyboardController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 654 of file pc98hw.c.

655{
656 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
657 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
658 PCONFIGURATION_COMPONENT_DATA ControllerKey;
659 ULONG Size;
660 UCHAR i;
661
662 if (!CpDoesPortExist((PUCHAR)0x41))
663 return;
664
665 /* Set 'Configuration Data' value */
668 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
669 if (PartialResourceList == NULL)
670 {
671 ERR("Failed to allocate resource descriptor\n");
672 return;
673 }
674 RtlZeroMemory(PartialResourceList, Size);
675 PartialResourceList->Version = 1;
676 PartialResourceList->Revision = 1;
677 PartialResourceList->Count = 3;
678
679 /* Set I/O ports */
680 for (i = 0; i < 2; i++)
681 {
682 PartialDescriptor = &PartialResourceList->PartialDescriptors[i];
683 PartialDescriptor->Type = CmResourceTypePort;
685 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
686 PartialDescriptor->u.Port.Start.LowPart = 0x41 + i * 2;
687 PartialDescriptor->u.Port.Start.HighPart = 0;
688 PartialDescriptor->u.Port.Length = 1;
689 }
690
691 /* Set Interrupt */
692 PartialDescriptor = &PartialResourceList->PartialDescriptors[2];
693 PartialDescriptor->Type = CmResourceTypeInterrupt;
695 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
696 PartialDescriptor->u.Interrupt.Level = 1;
697 PartialDescriptor->u.Interrupt.Vector = 1;
698 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
699
700 /* Create controller key */
705 0,
706 0xFFFFFFFF,
707 NULL,
708 PartialResourceList,
709 Size,
710 &ControllerKey);
711
712 DetectKeyboardPeripheral(ControllerKey);
713}
BOOLEAN NTAPI CpDoesPortExist(IN PUCHAR Address)
Definition: cport.c:224
static VOID DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: pc98hw.c:581
@ KeyboardController
Definition: arc.h:126
@ ConsoleIn
Definition: arc.h:82
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by DetectCBusBios().

◆ DetectKeyboardPeripheral()

static VOID DetectKeyboardPeripheral ( PCONFIGURATION_COMPONENT_DATA  ControllerKey)
static

Definition at line 581 of file pc98hw.c.

582{
583 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
584 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
585 PCM_KEYBOARD_DEVICE_DATA KeyboardData;
586 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
588 ULONG Size;
589 REGS Regs;
590 UCHAR KeyboardType = ((*(PUCHAR)MEM_KEYB_TYPE & 0x40) >> 5) |
591 ((*(PUCHAR)MEM_KEYB_TYPE & 0x08) >> 3);
592
593 /* TODO: Properly detect */
594
595 /* Set 'Configuration Data' value */
598 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
599 if (PartialResourceList == NULL)
600 {
601 ERR("Failed to allocate resource descriptor\n");
602 return;
603 }
604 RtlZeroMemory(PartialResourceList, Size);
605 PartialResourceList->Version = 1;
606 PartialResourceList->Revision = 1;
607 PartialResourceList->Count = 1;
608
609 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
610 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
612 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_KEYBOARD_DEVICE_DATA);
613
614 /* Int 18h AH=02h
615 * KEYBOARD - GET SHIFT FLAGS
616 *
617 * Return:
618 * AL - shift flags
619 */
620 Regs.b.ah = 0x02;
621 Int386(0x18, &Regs, &Regs);
622
623 KeyboardData = (PCM_KEYBOARD_DEVICE_DATA)(PartialDescriptor + 1);
624 KeyboardData->Version = 1;
625 KeyboardData->Revision = 1;
626 KeyboardData->Type = 7;
627 KeyboardData->Subtype = 1;
628 KeyboardData->KeyboardFlags = (Regs.b.al & 0x08) |
629 ((Regs.b.al & 0x02) << 6) |
630 ((Regs.b.al & 0x10) << 2) |
631 ((Regs.b.al & 0x01) << 1);
632
633 if (KeyboardType == 0)
634 Identifier = "PC98_NmodeKEY";
635 else if (KeyboardType == 2)
636 Identifier = "PC98_106KEY";
637 else
638 Identifier = "PC98_LaptopKEY";
639
640 /* Create controller key */
641 FldrCreateComponentKey(ControllerKey,
645 0,
646 0xFFFFFFFF,
648 PartialResourceList,
649 Size,
650 &PeripheralKey);
651}
#define MEM_KEYB_TYPE
Definition: machpc98.h:27
int __cdecl Int386(int ivec, REGS *in, REGS *out)
@ KeyboardPeripheral
Definition: arc.h:136
unsigned char al
Definition: pcbios.h:131
unsigned char ah
Definition: pcbios.h:132
Definition: pcbios.h:159
BYTEREGS b
Definition: pcbios.h:163
struct _CM_KEYBOARD_DEVICE_DATA * PCM_KEYBOARD_DEVICE_DATA
struct _CM_KEYBOARD_DEVICE_DATA CM_KEYBOARD_DEVICE_DATA

Referenced by DetectKeyboardController().

◆ DetectNesaBios()

static VOID DetectNesaBios ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
ULONG BusNumber 
)
static

Definition at line 1009 of file pc98hw.c.

1010{
1011 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1013 ULONG Size;
1014
1015 if (!((*(PUCHAR)MEM_BIOS_FLAG5) & NESA_BUS_FLAG))
1016 return;
1017
1018 /* Set 'Configuration Data' value */
1019 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
1021 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1022 if (PartialResourceList == NULL)
1023 {
1024 ERR("Failed to allocate resource descriptor\n");
1025 return;
1026 }
1027 RtlZeroMemory(PartialResourceList, Size);
1028 PartialResourceList->Version = 1;
1029 PartialResourceList->Revision = 1;
1030 PartialResourceList->Count = 0;
1031
1032 /* Create bus key */
1033 FldrCreateComponentKey(SystemKey,
1036 0,
1037 0,
1038 0xFFFFFFFF,
1039 "EISA",
1040 PartialResourceList,
1041 Size,
1042 &BusKey);
1043
1044 /* Increment bus number */
1045 (*BusNumber)++;
1046}
#define MEM_BIOS_FLAG5
Definition: machpc98.h:21
#define NESA_BUS_FLAG
Definition: machpc98.h:22

Referenced by Pc98HwDetect().

◆ DetectParallelPorts()

static VOID DetectParallelPorts ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 716 of file pc98hw.c.

717{
718 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
719 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
720 PCONFIGURATION_COMPONENT_DATA ControllerKey;
721 ULONG Size;
722 UCHAR i;
723 UCHAR Index = 0;
724
725 /* TODO: Properly detect */
726
727 /* Set 'Configuration Data' value */
730 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
731 if (PartialResourceList == NULL)
732 {
733 ERR("Failed to allocate resource descriptor\n");
734 return;
735 }
736 RtlZeroMemory(PartialResourceList, Size);
737 PartialResourceList->Version = 1;
738 PartialResourceList->Revision = 1;
739 PartialResourceList->Count = 8;
740
741 /* Set I/O ports */
742 for (i = 0; i < 4; i++)
743 {
744 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
745 PartialDescriptor->Type = CmResourceTypePort;
747 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
748 PartialDescriptor->u.Port.Start.LowPart = 0x40 + i * 2;
749 PartialDescriptor->u.Port.Start.HighPart = 0;
750 PartialDescriptor->u.Port.Length = 3;
751 }
752
753 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
754 PartialDescriptor->Type = CmResourceTypePort;
756 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
757 PartialDescriptor->u.Port.Start.LowPart = 0x140;
758 PartialDescriptor->u.Port.Start.HighPart = 0;
759 PartialDescriptor->u.Port.Length = 3;
760
761 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
762 PartialDescriptor->Type = CmResourceTypePort;
764 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
765 PartialDescriptor->u.Port.Start.LowPart = 0x149;
766 PartialDescriptor->u.Port.Start.HighPart = 0;
767 PartialDescriptor->u.Port.Length = 1;
768
769 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
770 PartialDescriptor->Type = CmResourceTypePort;
772 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
773 PartialDescriptor->u.Port.Start.LowPart = 0x14B;
774 PartialDescriptor->u.Port.Start.HighPart = 0;
775 PartialDescriptor->u.Port.Length = 4;
776
777 /* Set Interrupt */
778 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
779 PartialDescriptor->Type = CmResourceTypeInterrupt;
781 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
782 PartialDescriptor->u.Interrupt.Level = 14;
783 PartialDescriptor->u.Interrupt.Vector = 14;
784 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
785
786 /* Create controller key */
790 Output,
791 0,
792 0xFFFFFFFF,
793 "PARALLEL1",
794 PartialResourceList,
795 Size,
796 &ControllerKey);
797}
@ ParallelController
Definition: arc.h:124

Referenced by DetectCBusBios().

◆ DetectPnpBios()

static VOID DetectPnpBios ( PCONFIGURATION_COMPONENT_DATA  SystemKey,
ULONG BusNumber 
)
static

Definition at line 1050 of file pc98hw.c.

1051{
1052 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
1056 ULONG x;
1057 ULONG NodeSize = 0;
1058 ULONG NodeCount = 0;
1060 ULONG FoundNodeCount;
1061 int i;
1062 ULONG PnpBufferSize;
1063 ULONG PnpBufferSizeLimit;
1064 ULONG Size;
1065 char *Ptr;
1066
1068 if (InstData == NULL || strncmp((CHAR*)InstData->Signature, "$PnP", 4))
1069 {
1070 TRACE("PnP-BIOS not supported\n");
1071 return;
1072 }
1073
1074 TRACE("PnP-BIOS supported\n");
1075 TRACE("Signature '%c%c%c%c'\n",
1076 InstData->Signature[0], InstData->Signature[1],
1077 InstData->Signature[2], InstData->Signature[3]);
1078
1079 x = PnpBiosGetDeviceNodeCount(&NodeSize, &NodeCount);
1080 if (x == 0x82)
1081 {
1082 TRACE("PnP-BIOS function 'Get Number of System Device Nodes' not supported\n");
1083 return;
1084 }
1085
1086 NodeCount &= 0xFF; // needed since some fscked up BIOSes return
1087 // wrong info (e.g. Mac Virtual PC)
1088 // e.g. look: http://my.execpc.com/~geezer/osd/pnp/pnp16.c
1089 if (x != 0 || NodeSize == 0 || NodeCount == 0)
1090 {
1091 ERR("PnP-BIOS failed to enumerate device nodes\n");
1092 return;
1093 }
1094 TRACE("MaxNodeSize %u NodeCount %u\n", NodeSize, NodeCount);
1095 TRACE("Estimated buffer size %u\n", NodeSize * NodeCount);
1096
1097 /* Set 'Configuration Data' value */
1098 PnpBufferSizeLimit = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK)
1099 + (NodeSize * NodeCount);
1100 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) + PnpBufferSizeLimit;
1101 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
1102 if (PartialResourceList == NULL)
1103 {
1104 ERR("Failed to allocate resource descriptor\n");
1105 return;
1106 }
1107
1108 /* Initialize resource descriptor */
1109 RtlZeroMemory(PartialResourceList, Size);
1110 PartialResourceList->Version = 1;
1111 PartialResourceList->Revision = 1;
1112 PartialResourceList->Count = 1;
1113 PartialResourceList->PartialDescriptors[0].Type =
1115 PartialResourceList->PartialDescriptors[0].ShareDisposition =
1117
1118 /* The buffer starts after PartialResourceList->PartialDescriptors[0] */
1119 Ptr = (char *)(PartialResourceList + 1);
1120
1121 /* Set installation check data */
1124 PnpBufferSize = sizeof(CM_PNP_BIOS_INSTALLATION_CHECK);
1125
1126 /* Copy device nodes */
1127 FoundNodeCount = 0;
1128 for (i = 0; i < 0xFF; i++)
1129 {
1130 NodeNumber = (UCHAR)i;
1131
1133 if (x == 0)
1134 {
1136
1137 TRACE("Node: %u Size %u (0x%x)\n",
1138 DeviceNode->Node,
1139 DeviceNode->Size,
1140 DeviceNode->Size);
1141
1142 if (PnpBufferSize + DeviceNode->Size > PnpBufferSizeLimit)
1143 {
1144 ERR("Buffer too small! Ignoring remaining device nodes. (i = %d)\n", i);
1145 break;
1146 }
1147
1149
1150 Ptr += DeviceNode->Size;
1151 PnpBufferSize += DeviceNode->Size;
1152
1153 FoundNodeCount++;
1154 if (FoundNodeCount >= NodeCount)
1155 break;
1156 }
1157 }
1158
1159 /* Set real data size */
1160 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
1161 PnpBufferSize;
1162 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) + PnpBufferSize;
1163
1164 TRACE("Real buffer size: %u\n", PnpBufferSize);
1165 TRACE("Resource size: %u\n", Size);
1166
1167 /* Create component key */
1168 FldrCreateComponentKey(SystemKey,
1171 0,
1172 0,
1173 0xFFFFFFFF,
1174 "PNP BIOS",
1175 PartialResourceList,
1176 Size,
1177 &BusKey);
1178
1179 (*BusNumber)++;
1180}
@ DeviceNode
Definition: Node.h:9
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define DiskReadBuffer
Definition: hardware.h:33
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
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
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Out_ PUSHORT NodeNumber
Definition: iofuncs.h:2574

Referenced by Pc98HwDetect().

◆ DetectPointerController()

static VOID DetectPointerController ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 504 of file pc98hw.c.

505{
506 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
507 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
508 PCONFIGURATION_COMPONENT_DATA ControllerKey;
509 ULONG Size;
510 UCHAR i;
511 UCHAR Index = 0;
512
513 /* Set 'Configuration Data' value */
516 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
517 if (PartialResourceList == NULL)
518 {
519 ERR("Failed to allocate resource descriptor\n");
520 return;
521 }
522 RtlZeroMemory(PartialResourceList, Size);
523 PartialResourceList->Version = 1;
524 PartialResourceList->Revision = 1;
525 PartialResourceList->Count = (HiResoMachine ? 7 : 6);
526
527 /* Set I/O ports */
528 for (i = 0; i < 4; i++)
529 {
530 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
531 PartialDescriptor->Type = CmResourceTypePort;
533 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
534 PartialDescriptor->u.Port.Start.LowPart = (HiResoMachine ? 0x61 : 0x7FD9) + i * 2;
535 PartialDescriptor->u.Port.Start.HighPart = 0;
536 PartialDescriptor->u.Port.Length = 1;
537 }
538 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
539 PartialDescriptor->Type = CmResourceTypePort;
541 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
542 PartialDescriptor->u.Port.Start.LowPart = (HiResoMachine ? 0x869 : 0xBFDB);
543 PartialDescriptor->u.Port.Start.HighPart = 0;
544 PartialDescriptor->u.Port.Length = 1;
545 if (HiResoMachine)
546 {
547 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
548 PartialDescriptor->Type = CmResourceTypePort;
550 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
551 PartialDescriptor->u.Port.Start.LowPart = 0x98D7;
552 PartialDescriptor->u.Port.Start.HighPart = 0;
553 PartialDescriptor->u.Port.Length = 1;
554 }
555
556 /* Set Interrupt */
557 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
558 PartialDescriptor->Type = CmResourceTypeInterrupt;
560 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
561 PartialDescriptor->u.Interrupt.Level = 13;
562 PartialDescriptor->u.Interrupt.Vector = 13;
563 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
564
565 /* Create controller key */
569 Input,
570 0,
571 0xFFFFFFFF,
572 NULL,
573 PartialResourceList,
574 Size,
575 &ControllerKey);
576
577 DetectPointerPeripheral(ControllerKey);
578}
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
static VOID DetectPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
Definition: pc98hw.c:468
BOOLEAN HiResoMachine
Definition: machpc98.c:17
@ PointerController
Definition: arc.h:125

Referenced by DetectCBusBios().

◆ DetectPointerPeripheral()

static VOID DetectPointerPeripheral ( PCONFIGURATION_COMPONENT_DATA  ControllerKey)
static

Definition at line 468 of file pc98hw.c.

469{
470 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
471 PCONFIGURATION_COMPONENT_DATA PeripheralKey;
472 ULONG Size;
473
474 /* TODO: Properly detect */
475
476 /* Set 'Configuration Data' value */
479 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
480 if (PartialResourceList == NULL)
481 {
482 ERR("Failed to allocate resource descriptor\n");
483 return;
484 }
485 RtlZeroMemory(PartialResourceList, Size);
486 PartialResourceList->Version = 1;
487 PartialResourceList->Revision = 1;
488 PartialResourceList->Count = 0;
489
490 /* Create 'PointerPeripheral' key */
491 FldrCreateComponentKey(ControllerKey,
494 Input,
495 0,
496 0xFFFFFFFF,
497 "NEC PC-9800 BUS MOUSE",
498 PartialResourceList,
499 Size,
500 &PeripheralKey);
501}
@ PointerPeripheral
Definition: arc.h:135

Referenced by DetectPointerController().

◆ DetectSerialPorts()

static VOID DetectSerialPorts ( PCONFIGURATION_COMPONENT_DATA  BusKey)
static

Definition at line 800 of file pc98hw.c.

801{
802 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
803 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
804 PCM_SERIAL_DEVICE_DATA SerialDeviceData;
805 PCONFIGURATION_COMPONENT_DATA ControllerKey;
806 CHAR Identifier[80];
807 UCHAR i;
808 ULONG Size;
809 UCHAR FifoStatus;
811 UCHAR Index = 0;
812 ULONG ControllerNumber = 0;
813
814 if (CpDoesPortExist((PUCHAR)0x30))
815 {
816 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "COM%d", ControllerNumber + 1);
817
818 FifoStatus = READ_PORT_UCHAR((PUCHAR)0x136) & 0x40;
820 HasFifo = ((READ_PORT_UCHAR((PUCHAR)0x136) & 0x40) != FifoStatus);
821
822 /* Set 'Configuration Data' value */
824 (HasFifo ? 10 : 3) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) +
825 sizeof(CM_SERIAL_DEVICE_DATA);
826 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
827 if (PartialResourceList == NULL)
828 {
829 ERR("Failed to allocate resource descriptor\n");
830 return;
831 }
832 RtlZeroMemory(PartialResourceList, Size);
833 PartialResourceList->Version = 1;
834 PartialResourceList->Revision = 1;
835 PartialResourceList->Count = (HasFifo ? 11 : 4);
836
837 /* Set I/O ports */
838 for (i = 0; i < 2; i++)
839 {
840 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
841 PartialDescriptor->Type = CmResourceTypePort;
843 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
844 PartialDescriptor->u.Port.Start.LowPart = 0x30 + i * 2;
845 PartialDescriptor->u.Port.Start.HighPart = 0;
846 PartialDescriptor->u.Port.Length = 1;
847 }
848 if (HasFifo)
849 {
850 for (i = 0; i < 7; i++)
851 {
852 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
853 PartialDescriptor->Type = CmResourceTypePort;
855 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
856 PartialDescriptor->u.Port.Start.LowPart = 0x130 + i * 2;
857 PartialDescriptor->u.Port.Start.HighPart = 0;
858 PartialDescriptor->u.Port.Length = 1;
859 }
860 }
861
862 /* Set Interrupt */
863 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
864 PartialDescriptor->Type = CmResourceTypeInterrupt;
866 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
867 PartialDescriptor->u.Interrupt.Level = 4;
868 PartialDescriptor->u.Interrupt.Vector = 4;
869 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
870
871 /* Set serial data (device specific) */
872 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
873 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
875 PartialDescriptor->Flags = 0;
876 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_SERIAL_DEVICE_DATA);
877
878 SerialDeviceData = (PCM_SERIAL_DEVICE_DATA)&PartialResourceList->PartialDescriptors[Index++];
879 SerialDeviceData->BaudClock = (*(PUCHAR)MEM_BIOS_FLAG1 & SYSTEM_CLOCK_8MHZ_FLAG) ?
881
882 /* Create controller key */
887 ControllerNumber,
888 0xFFFFFFFF,
890 PartialResourceList,
891 Size,
892 &ControllerKey);
893
894 ++ControllerNumber;
895 }
896
897 if (CpDoesPortExist((PUCHAR)0x238))
898 {
899 Index = 0;
900
901 RtlStringCbPrintfA(Identifier, sizeof(Identifier), "COM%d", ControllerNumber + 1);
902
903 /* Set 'Configuration Data' value */
906 sizeof(CM_SERIAL_DEVICE_DATA);
907 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
908 if (PartialResourceList == NULL)
909 {
910 ERR("Failed to allocate resource descriptor\n");
911 return;
912 }
913 RtlZeroMemory(PartialResourceList, Size);
914 PartialResourceList->Version = 1;
915 PartialResourceList->Revision = 1;
916 PartialResourceList->Count = 3;
917
918 /* Set I/O ports */
919 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
920 PartialDescriptor->Type = CmResourceTypePort;
922 PartialDescriptor->Flags = CM_RESOURCE_PORT_IO;
923 PartialDescriptor->u.Port.Start.LowPart = 0x238;
924 PartialDescriptor->u.Port.Start.HighPart = 0;
925 PartialDescriptor->u.Port.Length = 8;
926
927 /* Set Interrupt */
928 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
929 PartialDescriptor->Type = CmResourceTypeInterrupt;
931 PartialDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
932 PartialDescriptor->u.Interrupt.Level = 5;
933 PartialDescriptor->u.Interrupt.Vector = 5;
934 PartialDescriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
935
936 /* Set serial data (device specific) */
937 PartialDescriptor = &PartialResourceList->PartialDescriptors[Index++];
938 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
940 PartialDescriptor->Flags = 0;
941 PartialDescriptor->u.DeviceSpecificData.DataSize = sizeof(CM_SERIAL_DEVICE_DATA);
942
943 SerialDeviceData = (PCM_SERIAL_DEVICE_DATA)&PartialResourceList->PartialDescriptors[Index++];
944 SerialDeviceData->BaudClock = 1843200;
945
946 /* Create controller key */
951 ControllerNumber,
952 0xFFFFFFFF,
954 PartialResourceList,
955 Size,
956 &ControllerKey);
957
958 ++ControllerNumber;
959 }
960}
unsigned char BOOLEAN
BOOLEAN HasFifo
Definition: cport_pc98.c:28
#define SYSTEM_CLOCK_8MHZ_FLAG
Definition: machpc98.h:38
#define MEM_BIOS_FLAG1
Definition: machpc98.h:35
VOID StallExecutionProcessor(ULONG Microseconds)
Definition: pc98hw.c:45
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
@ SerialController
Definition: arc.h:121
@ ConsoleOut
Definition: arc.h:83
#define TIMER_FREQUENCY_1
Definition: pit.h:16
#define TIMER_FREQUENCY_2
Definition: pit.h:17
struct _CM_SERIAL_DEVICE_DATA * PCM_SERIAL_DEVICE_DATA
struct _CM_SERIAL_DEVICE_DATA CM_SERIAL_DEVICE_DATA

Referenced by DetectCBusBios().

◆ DiskStopFloppyMotor()

VOID __cdecl DiskStopFloppyMotor ( VOID  )

Definition at line 1235 of file pc98hw.c.

1236{
1239}
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#define FDC1_IO_BASE
Definition: fdc.h:10
#define FDC2_IO_BASE
Definition: fdc.h:11
#define FDC_o_CONTROL
Definition: fdc.h:22

Referenced by Pc98PrepareForReactOS(), PcPrepareForReactOS(), and XboxPrepareForReactOS().

◆ FrLdrCheckCpuCompatibility()

VOID FrLdrCheckCpuCompatibility ( VOID  )

Definition at line 1243 of file pc98hw.c.

1244{
1245 INT CpuInformation[4] = {-1};
1246 ULONG NumberOfIds;
1247
1248 /* Check if the processor first supports ID 1 */
1249 __cpuid(CpuInformation, 0);
1250
1251 NumberOfIds = CpuInformation[0];
1252
1253 if (NumberOfIds == 0)
1254 {
1256 __FILE__,
1257 __LINE__,
1258 "ReactOS requires the CPUID instruction to return "
1259 "more than one supported ID.\n\n");
1260 }
1261
1262 /* NumberOfIds will be greater than 1 if the processor is new enough */
1263 if (NumberOfIds == 1)
1264 {
1265 INT ProcessorFamily;
1266
1267 /* Get information */
1268 __cpuid(CpuInformation, 1);
1269
1270 ProcessorFamily = (CpuInformation[0] >> 8) & 0xF;
1271
1272 /* If it's Family 4 or lower, bugcheck */
1273 if (ProcessorFamily < 5)
1274 {
1276 __FILE__,
1277 __LINE__,
1278 "Processor is too old (family %u < 5)\n"
1279 "ReactOS requires a Pentium-level processor or newer.",
1280 ProcessorFamily);
1281 }
1282 }
1283}
VOID FrLdrBugCheckWithMessage(ULONG BugCode, PCHAR File, ULONG Line, PSTR Format,...)
Definition: debug.c:28
@ MISSING_HARDWARE_REQUIREMENTS
Definition: debug.h:141
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
Definition: intrin_ppc.h:682
int32_t INT
Definition: typedefs.h:58

◆ GetFloppyType()

static UCHAR GetFloppyType ( UCHAR  FloppyNumber)
static

Definition at line 143 of file pc98hw.c.

144{
145 /* FIXME */
146 return 5;
147}

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().

◆ HalpCalibrateStallExecution()

VOID HalpCalibrateStallExecution ( VOID  )

Definition at line 70 of file pc98hw.c.

71{
72 ULONG i;
73 ULONG calib_bit;
74 ULONG CurCount;
75 TIMER_CONTROL_PORT_REGISTER TimerControl;
78
79 /* Initialize timer interrupt with MILLISECOND ms interval */
80 TimerControl.BcdMode = FALSE;
81 TimerControl.OperatingMode = PitOperatingMode2;
82 TimerControl.AccessMode = PitAccessModeLowHigh;
83 TimerControl.Channel = PitChannel0;
84 Write8253Timer(TimerControl, Count);
85
86 /* Stage 1: Coarse calibration */
87
88 delay_count = 1;
89
90 do
91 {
92 /* Next delay count to try */
93 delay_count <<= 1;
94
96
97 /* Do the delay */
99
100 CurCount = Read8253Timer(PitChannel0);
101 }
102 while (CurCount > Count / 2);
103
104 /* Get bottom value for delay */
105 delay_count >>= 1;
106
107 /* Stage 2: Fine calibration */
108
109 /* Which bit are we going to test */
110 calib_bit = delay_count;
111
112 for (i = 0; i < PRECISION; i++)
113 {
114 /* Next bit to calibrate */
115 calib_bit >>= 1;
116
117 /* If we have done all bits, stop */
118 if (!calib_bit)
119 break;
120
121 /* Set the bit in delay_count */
122 delay_count |= calib_bit;
123
125
126 /* Do the delay */
128
129 CurCount = Read8253Timer(PitChannel0);
130
131 /* If a tick has passed, turn the calibrated bit back off */
132 if (CurCount <= Count / 2)
133 delay_count &= ~calib_bit;
134 }
135
136 /* We're finished: Do the finishing touches */
137
138 /* Calculate delay_count for 1ms */
139 delay_count /= (MILLISEC / 2);
140}
#define FALSE
Definition: types.h:117
@ PitChannel0
Definition: halhw.h:102
@ PitAccessModeLowHigh
Definition: halhw.h:97
@ PitOperatingMode2
Definition: halhw.h:84
int Count
Definition: noreturn.cpp:7
#define MILLISEC
Definition: pc98hw.c:27
static VOID WaitFor8253Wraparound(VOID)
Definition: pc98hw.c:52
static VOID __StallExecutionProcessor(ULONG Loops)
Definition: pc98hw.c:39
#define HZ
Definition: pc98hw.c:29
#define PRECISION
Definition: pc98hw.c:28
static unsigned int delay_count
Definition: pc98hw.c:31
FORCEINLINE ULONG Read8253Timer(TIMER_CHANNELS TimerChannel)
Definition: pit.h:77
FORCEINLINE VOID Write8253Timer(TIMER_CONTROL_PORT_REGISTER TimerControl, USHORT Count)
Definition: pit.h:90

◆ Pc98GetFloppyCount()

UCHAR Pc98GetFloppyCount ( VOID  )

Definition at line 1214 of file pc98hw.c.

1215{
1216 USHORT DiskEquipment = *(PUSHORT)MEM_DISK_EQUIP & ~(*(PUCHAR)MEM_RDISK_EQUIP);
1217 UCHAR DiskMask;
1218 UCHAR FloppyCount = 0;
1219
1220 for (DiskMask = 0x01; DiskMask != 0; DiskMask <<= 1)
1221 {
1222 if (FIRSTBYTE(DiskEquipment) & DiskMask)
1223 ++FloppyCount;
1224 }
1225
1226 for (DiskMask = 0x10; DiskMask != 0; DiskMask <<= 1)
1227 {
1228 if (SECONDBYTE(DiskEquipment) & DiskMask)
1229 ++FloppyCount;
1230 }
1231
1232 return FloppyCount;
1233}
#define MEM_RDISK_EQUIP
Definition: machpc98.h:33
#define MEM_DISK_EQUIP
Definition: machpc98.h:41
uint16_t * PUSHORT
Definition: typedefs.h:56
#define SECONDBYTE(VALUE)
Definition: rtlfuncs.h:796
#define FIRSTBYTE(VALUE)
Definition: rtlfuncs.h:795

Referenced by DetectBiosFloppyController(), DetectBiosFloppyPeripheral(), and MachInit().

◆ Pc98GetHarddiskConfigurationData()

static PCM_PARTIAL_RESOURCE_LIST Pc98GetHarddiskConfigurationData ( UCHAR  DriveNumber,
ULONG pSize 
)
static

Definition at line 316 of file pc98hw.c.

317{
318 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
320 GEOMETRY Geometry;
321 ULONG Size;
322
323 *pSize = 0;
324
325 /* Set 'Configuration Data' value */
328 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
329 if (PartialResourceList == NULL)
330 {
331 ERR("Failed to allocate resource descriptor\n");
332 return NULL;
333 }
334 RtlZeroMemory(PartialResourceList, Size);
335 PartialResourceList->Version = 1;
336 PartialResourceList->Revision = 1;
337 PartialResourceList->Count = 1;
338 PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeDeviceSpecific;
339// PartialResourceList->PartialDescriptors[0].ShareDisposition =
340// PartialResourceList->PartialDescriptors[0].Flags =
341 PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
343
344 /* Get pointer to geometry data */
345 DiskGeometry = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
346
347 /* Get the disk geometry. Extended geometry isn't supported by hardware */
348 if (Pc98DiskGetDriveGeometry(DriveNumber, &Geometry))
349 {
350 DiskGeometry->BytesPerSector = Geometry.BytesPerSector;
351 DiskGeometry->NumberOfCylinders = Geometry.Cylinders;
352 DiskGeometry->SectorsPerTrack = Geometry.Sectors;
353 DiskGeometry->NumberOfHeads = Geometry.Heads;
354 }
355 else
356 {
357 TRACE("Reading disk geometry failed\n");
358 FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
359 return NULL;
360 }
361 TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
362 DriveNumber,
363 DiskGeometry->NumberOfCylinders,
364 DiskGeometry->NumberOfHeads,
365 DiskGeometry->SectorsPerTrack,
366 DiskGeometry->BytesPerSector);
367
368 *pSize = Size;
369 return PartialResourceList;
370}
FORCEINLINE VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: mm.h:181
struct _CM_DISK_GEOMETRY_DEVICE_DATA CM_DISK_GEOMETRY_DEVICE_DATA

Referenced by Pc98HwDetect().

◆ Pc98HwDetect()

PCONFIGURATION_COMPONENT_DATA Pc98HwDetect ( _In_opt_ PCSTR  Options)

Definition at line 1183 of file pc98hw.c.

1185{
1187 ULONG BusNumber = 0;
1188
1189 TRACE("DetectHardware()\n");
1190
1191 /* Create the 'System' key */
1192 FldrCreateSystemKey(&SystemKey, "NEC PC-98");
1193
1196
1197 /* Detect buses */
1198 DetectPciBios(SystemKey, &BusNumber);
1199 DetectApmBios(SystemKey, &BusNumber);
1200 DetectPnpBios(SystemKey, &BusNumber);
1201 DetectNesaBios(SystemKey, &BusNumber);
1202 DetectCBusBios(SystemKey, &BusNumber);
1203 DetectAcpiBios(SystemKey, &BusNumber);
1204 // TODO: Detect more buses
1205
1206 // TODO: Collect the ROM blocks and append their
1207 // CM_ROM_BLOCK data into the 'System' key's configuration data.
1208
1209 TRACE("DetectHardware() Done\n");
1210 return SystemKey;
1211}
VOID FldrCreateSystemKey(_Out_ PCONFIGURATION_COMPONENT_DATA *SystemNode, _In_ PCSTR IdentifierString)
Definition: archwsup.c:135
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwacpi.c:54
VOID DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwpci.c:176
BOOLEAN PcFindPciBios(PPCI_REGISTRY_INFO BusData)
Definition: hwpci.c:80
FIND_PCI_BIOS FindPciBios
Definition: hwpci.c:26
VOID DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwapm.c:46
static VOID DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: pc98hw.c:1050
static VOID DetectNesaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: pc98hw.c:1009
static PCM_PARTIAL_RESOURCE_LIST Pc98GetHarddiskConfigurationData(UCHAR DriveNumber, ULONG *pSize)
Definition: pc98hw.c:316
static VOID DetectCBusBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: pc98hw.c:963
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160

Referenced by MachInit().

◆ StallExecutionProcessor()

VOID StallExecutionProcessor ( ULONG  Microseconds)

Definition at line 45 of file pc98hw.c.

46{
47 ULONGLONG LoopCount = ((ULONGLONG)delay_count * (ULONGLONG)Microseconds) / 1000ULL;
49}
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by DetectSerialPorts().

◆ WaitFor8253Wraparound()

static VOID WaitFor8253Wraparound ( VOID  )
static

Definition at line 52 of file pc98hw.c.

53{
54 ULONG CurrentCount;
55 ULONG PreviousCount = ~0;
56 LONG Delta;
57
58 CurrentCount = Read8253Timer(PitChannel0);
59
60 do
61 {
62 PreviousCount = CurrentCount;
63 CurrentCount = Read8253Timer(PitChannel0);
64 Delta = CurrentCount - PreviousCount;
65 }
66 while (Delta < 300);
67}
long LONG
Definition: pedump.c:60
static ULONG Delta
Definition: xboxvideo.c:33

Referenced by HalpCalibrateStallExecution().

Variable Documentation

◆ delay_count

unsigned int delay_count = 1
static

Definition at line 31 of file pc98hw.c.

Referenced by HalpCalibrateStallExecution(), and StallExecutionProcessor().

◆ GetHarddiskConfigurationData

GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData = NULL

Definition at line 23 of file pc98hw.c.

Referenced by DetectBiosDisks(), and Pc98HwDetect().

◆ HiResoMachine

BOOLEAN HiResoMachine
extern

Definition at line 17 of file machpc98.c.

Referenced by DetectPointerController().

◆ PcBiosDiskCount

UCHAR PcBiosDiskCount
extern

Definition at line 43 of file hwdisk.c.

Referenced by DetectBiosDisks().