From 4c2fa234c4c092a9872b0c8a31ccd85357a2d249 Mon Sep 17 00:00:00 2001 From: Dmitry Borisov Date: Mon, 22 Jun 2026 18:06:15 +0600 Subject: [PATCH] [FREELDR:PC98] Report a more detailed system ID for sysdm control panel (#9194) Report the machine model name for better user experience. CORE-17977 --- boot/freeldr/freeldr/arch/i386/pc98/pc98hw.c | 68 +++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/boot/freeldr/freeldr/arch/i386/pc98/pc98hw.c b/boot/freeldr/freeldr/arch/i386/pc98/pc98hw.c index e7a2cb6e9d7..f6964e2aa0d 100644 --- a/boot/freeldr/freeldr/arch/i386/pc98/pc98hw.c +++ b/boot/freeldr/freeldr/arch/i386/pc98/pc98hw.c @@ -1161,6 +1161,72 @@ DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber) (*BusNumber)++; } +static +PCSTR +GetPc9821SystemIdentifier( + _In_ UCHAR Id) +{ + switch (Id) + { + case 0x27: return "Lt2"; + case 0x30: return "Cx3"; + case 0x40: return "Ct16"; + case 0x59: return "V166"; + case 0x5F: return "Nr166"; + case 0x73: return "Ra333"; + default: return NULL; + } +} + +static +VOID +CreateSystemKey( + _Inout_ PCONFIGURATION_COMPONENT_DATA* SystemKey) +{ + const ULONG IdentifierSize = 256; + PCHAR Identifier; + + /* The kernel expects the PC-98 identifier string to begin with 'NEC PC-98' */ +#define PC98_DEFAULT_ID "NEC PC-98" + + Identifier = FrLdrHeapAlloc(IdentifierSize, TAG_HW_RESOURCE_LIST); + if (!Identifier) + return; + + /* Check if this machine is NEC PC-9821 */ + if (*(PUSHORT)MEM_EXTENDED_NORMAL == 0x2198) + { + UCHAR Id = *((PUCHAR)MEM_EXTENDED_NORMAL + 0x3F); + PCSTR IdString; + + IdString = GetPc9821SystemIdentifier(Id); + if (!IdString) + { + /* Unknown values should be visible in sysdm control panel for bug reports */ + ERR("Unknown PC-9821 model %02X\n", Id); + RtlStringCbPrintfA(Identifier, + IdentifierSize, + PC98_DEFAULT_ID "21 Unknown model %02X", + Id); + } + else + { + RtlStringCbPrintfA(Identifier, + IdentifierSize, + PC98_DEFAULT_ID "21 %s", + IdString); + } + } + else + { + RtlStringCbCopyA(Identifier, IdentifierSize, PC98_DEFAULT_ID); + } + TRACE("System identifier '%s'\n", Identifier); + + FldrCreateSystemKey(SystemKey, Identifier); + FrLdrHeapFree(Identifier, TAG_HW_RESOURCE_LIST); +} + PCONFIGURATION_COMPONENT_DATA Pc98HwDetect( _In_opt_ PCSTR Options) @@ -1171,7 +1237,7 @@ Pc98HwDetect( TRACE("DetectHardware()\n"); /* Create the 'System' key */ - FldrCreateSystemKey(&SystemKey, "NEC PC-98"); + CreateSystemKey(&SystemKey); GetHarddiskConfigurationData = Pc98GetHarddiskConfigurationData;