Skip to content

Commit 1691c8d

Browse files
committed
[NTOS:CM] Detect NEC PC-98 alternative system architecture dynamically
Perform detection by matching system identifier passed from the loader block, similarly to how FreeLoader detects the boot video driver: https://github.com/reactos/reactos/blob/332331ce1b7a71b0227b9ec3d4449272b28a84f6/boot/freeldr/freeldr/ntldr/winldr.c#L653 Windows checks if the identifier starts with a known string and then sets additional flags for the drivers. Follow up of 8df1b53. CORE-17977
1 parent 332331c commit 1691c8d

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

ntoskrnl/config/cmconfig.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,6 @@ CmpInitializeHardwareConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
334334
ULONG Disposition;
335335
UNICODE_STRING KeyName;
336336

337-
/* Set the alternative system architecture information */
338-
#if defined(SARCH_PC98)
339-
SharedUserData->AlternativeArchitecture = NEC98x86;
340-
#endif
341-
342337
/* Setup the key name */
343338
RtlInitUnicodeString(&KeyName,
344339
L"\\Registry\\Machine\\Hardware\\DeviceMap");
@@ -399,6 +394,30 @@ CmpInitializeHardwareConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
399394
/* Check if we got anything from NTLDR */
400395
if (LoaderBlock->ConfigurationRoot)
401396
{
397+
#ifdef _M_IX86
398+
/* Set the alternative system architecture information */
399+
const CHAR SystemId_PC98[] = "NEC PC-98";
400+
401+
PCONFIGURATION_COMPONENT_DATA ConfigData;
402+
ConfigData = KeFindConfigurationEntry(LoaderBlock->ConfigurationRoot,
403+
SystemClass,
404+
MaximumType,
405+
NULL);
406+
if (ConfigData)
407+
{
408+
/* Check if the system identifier starts with a known string.
409+
* Set kernel flags and initialize variables accordingly. */
410+
if (RtlCompareMemory(ConfigData->ComponentEntry.Identifier,
411+
SystemId_PC98,
412+
sizeof(SystemId_PC98) - 1) == sizeof(SystemId_PC98) - 1)
413+
{
414+
/* Running on a NEC PC-9800 or compatible */
415+
KeI386MachineType |= 0x100; /* Should probably be one of MACHINE_TYPE_* consts */
416+
SharedUserData->AlternativeArchitecture = NEC98x86;
417+
}
418+
}
419+
#endif
420+
402421
/* Setup the configuration tree */
403422
Status = CmpSetupConfigurationTree(LoaderBlock->ConfigurationRoot,
404423
KeyHandle,

ntoskrnl/include/internal/i386/ke.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ extern ULONG KeI386FxsrPresent;
732732
extern ULONG KiMXCsrMask;
733733
extern ULONG KeI386CpuType;
734734
extern ULONG KeI386CpuStep;
735+
extern ULONG KeI386MachineType;
735736
extern ULONG KiFastSystemCallDisable;
736737
extern UCHAR KiDebugRegisterTrapOffsets[9];
737738
extern UCHAR KiDebugRegisterContextOffsets[9];

0 commit comments

Comments
 (0)