[NTOS:PNP] Assign correct PnP IDs to the devices detected by bootloader

Based on a commit by Vadim Galyant:
5ef5c11e7f

Also fix a minor type conversion warning. CORE-18963 CORE-17977

Co-authored-by: Vadim Galyant <vgal@rambler.ru>
This commit is contained in:
Stanislav Motylkov 2023-05-20 15:56:52 +03:00
parent 114bc2b96e
commit 7d5e159131
4 changed files with 96 additions and 36 deletions

View file

@ -98,6 +98,9 @@ HKLM,"SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\PCI#CC_0301","Clas
HKLM,"SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\*PNP0303","Service",0x00000000,"i8042prt"
HKLM,"SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\*PNP0303","ClassGUID",0x00000000,"{4D36E96B-E325-11CE-BFC1-08002BE10318}"
HKLM,"SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\*PNP030B","Service",0x00000000,"i8042prt"
HKLM,"SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\*PNP030B","ClassGUID",0x00000000,"{4D36E96B-E325-11CE-BFC1-08002BE10318}"
HKLM,"SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\*PNP0F0E","Service",0x00000000,"i8042prt"
HKLM,"SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\*PNP0F0E","ClassGUID",0x00000000,"{4D36E96F-E325-11CE-BFC1-08002BE10318}"

View file

@ -176,6 +176,7 @@ GenDisk = disk,{4D36E967-E325-11CE-BFC1-08002BE10318}
USB\Class_03 = hidusb
GENERIC_HID_DEVICE = hidusb
*PNP0303 = i8042prt,{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP030B = i8042prt,{4D36E96B-E325-11CE-BFC1-08002BE10318}
*nEC1F00 = inport,{4D36E96F-E325-11CE-BFC1-08002BE10318}
ROOT\SWENUM = swenum

View file

@ -29,6 +29,7 @@ HKR, , UpperFilters, 0x00010000, "kbdclass"
[StdMfg]
%*PNP0303.DeviceDesc% = PS2_Inst.NT,*PNP0303
%*PNP030B.DeviceDesc% = PS2_Inst.NT,*PNP030B
%HID.KeyboardDevice% = HID_Keyboard_Inst,,HID_DEVICE_SYSTEM_KEYBOARD
;------------------------------ HID DRIVER ------------------------------
@ -105,7 +106,8 @@ ReactOS = "ReactOS Project"
KeyboardClassName = "Keyboards"
StdMfg = "(Standard keyboards)"
*PNP0303.DeviceDesc = "IBM PC/AT keyboard"
*PNP0303.DeviceDesc = "Standard 101/102-key or Microsoft Natural PS/2 keyboard"
*PNP030B.DeviceDesc = "PC/AT Enhanced PS/2 keyboard (101/102-key)"
LocationOverride = "plugged in to keyboard port"
HID.KeyboardDevice = "HID-Keyboard"
@ -113,7 +115,6 @@ HID.KeyboardDevice = "HID-Keyboard"
KeyboardClassName = "鍵盤"
StdMfg = "(標準鍵盤)"
*PNP0303.DeviceDesc = "IBM PC/AT 鍵盤"
HID.KeyboardDevice = "HID 鍵盤"
[Strings.0405]
@ -128,7 +129,6 @@ HID.KeyboardDevice = "Klávesnice standardu HID"
KeyboardClassName = "Tastaturen"
StdMfg = "(Standard-Tastaturen)"
*PNP0303.DeviceDesc = "IBM PC/AT Tastatur"
LocationOverride = "eingesteckt in Tastaturanschluss"
HID.KeyboardDevice = "HID-Tastatur"
@ -136,33 +136,28 @@ HID.KeyboardDevice = "HID-Tastatur"
KeyboardClassName = "Πληκτρολόγια"
StdMfg = "(Πρότυπα πληκτρολόγια)"
*PNP0303.DeviceDesc = "IBM PC/AT πληκτρολόγιο"
[Strings.0a]
KeyboardClassName = "Teclados"
StdMfg = "(Teclado estándar)"
*PNP0303.DeviceDesc = "Teclado IBM PC/AT"
LocationOverride = "se conecta al puerto de teclado"
[Strings.040C]
KeyboardClassName = "Claviers"
StdMfg = "(Claviers standards)"
*PNP0303.DeviceDesc = "Clavier IBM PC/AT"
LocationOverride = "Branché sur le port clavier"
[Strings.0411]
KeyboardClassName = "キーボード"
StdMfg = "(スタンダード キーボード)"
*PNP0303.DeviceDesc = "IBM PC/AT キーボード"
[Strings.0415]
KeyboardClassName = "Klawiatury"
StdMfg = "(Klawiatury standardowe)"
*PNP0303.DeviceDesc = "Klawiatura IBM PC/AT"
LocationOverride = "podłaczone do portu klawiatury"
HID.KeyboardDevice = "Klawiatura HID"
@ -170,13 +165,11 @@ HID.KeyboardDevice = "Klawiatura HID"
KeyboardClassName = "Teclados"
StdMfg = "(Teclado padrão)"
*PNP0303.DeviceDesc = "Teclado IBM PC/AT"
[Strings.0418]
KeyboardClassName = "Tastaturi"
StdMfg = "(tastatură standard)"
*PNP0303.DeviceDesc = "Tastatură IBM PC/AT"
LocationOverride = "conectat la portul de tastatură"
HID.KeyboardDevice = "Tastatură-dispozitiv de interfațare umană"
@ -184,7 +177,8 @@ HID.KeyboardDevice = "Tastatură-dispozitiv de interfațare umană"
KeyboardClassName = "Клавиатуры"
StdMfg = "(Стандартные клавиатуры)"
*PNP0303.DeviceDesc = "Клавиатура IBM PC/AT"
*PNP0303.DeviceDesc = "Стандартная (101/102 клавиши) или клавиатура PS/2 Microsoft Natural"
*PNP030B.DeviceDesc = "Расширенная клавиатура PS/2 PC/AT (101/102 клавиши)"
LocationOverride = "подключено к порту клавиатуры"
HID.KeyboardDevice = "Клавиатура HID"
@ -192,13 +186,11 @@ HID.KeyboardDevice = "Клавиатура HID"
KeyboardClassName = "Klávesnice"
StdMfg = "(Štandardné klávesnice)"
*PNP0303.DeviceDesc = "Klávesnica IBM PC/AT"
[Strings.041f]
KeyboardClassName = "Klavyeler"
StdMfg = "(Standart Klavyeler)"
*PNP0303.DeviceDesc = "IBM PC/AT Klavye"
LocationOverride = "klavye girişine takılı"
HID.KeyboardDevice = "HID Klavyeler"
@ -206,7 +198,6 @@ HID.KeyboardDevice = "HID Klavyeler"
KeyboardClassName = "Клавіатури"
StdMfg = "(Стандартні клавіатури)"
*PNP0303.DeviceDesc = "Клавіатура IBM PC/AT"
LocationOverride = "приєднано до порту клавітури"
HID.KeyboardDevice = "HID-Клавіатура"
@ -214,23 +205,19 @@ HID.KeyboardDevice = "HID-Клавіатура"
KeyboardClassName = "Klaviatūros"
StdMfg = "(Standartinė klaviatūra)"
*PNP0303.DeviceDesc = "IBM PC/AT klaviatūra"
[Strings.0804]
HID.KeyboardDevice = "HID 键盘"
StdMfg = "(标准键盘)"
*PNP0303.DeviceDesc = "IBM PC/AT 键盘"
[Strings.0816]
KeyboardClassName = "Teclados"
StdMfg = "(Teclado padrão)"
*PNP0303.DeviceDesc = "Teclado IBM PC/AT"
[Strings.0C04]
KeyboardClassName = "鍵盤"
StdMfg = "(標準鍵盤)"
*PNP0303.DeviceDesc = "IBM PC/AT 鍵盤"
HID.KeyboardDevice = "HID 鍵盤"

View file

@ -14,10 +14,17 @@
/* TYPES *********************************************************************/
typedef struct _PNP_MAPPER_DEVICE_ID
{
PCWSTR TypeName;
PWSTR PnPId;
} PNP_MAPPER_DEVICE_ID, *PPNP_MAPPER_DEVICE_ID;
typedef struct _PNP_DETECT_IDENTIFIER_MAP
{
PWSTR DetectId;
PCWSTR DetectId;
PWSTR PnPId;
PPNP_MAPPER_DEVICE_ID PeripheralMap;
ULONG Counter;
} PNP_DETECT_IDENTIFIER_MAP;
@ -29,33 +36,92 @@ static UNICODE_STRING ConfigurationDataU = RTL_CONSTANT_STRING(L"Configuration D
static UNICODE_STRING BootConfigU = RTL_CONSTANT_STRING(L"BootConfig");
static UNICODE_STRING LogConfU = RTL_CONSTANT_STRING(L"LogConf");
/* FIXME: There should be two sets of hardcoded PnP identifiers
* for the keyboard and pointer peripherals (see CORE-18963).
* They also can be parsed from a LegacyXlate sections of driver INF files.
*/
/* FIXME: Trailing \0 in structures below are hacks, should be removed.
* Hardware identifiers also can be mapped using "LegacyXlate" sections
* of driver INF files. */
DATA_SEG("INITDATA")
static
PNP_MAPPER_DEVICE_ID KeyboardMap[] =
{
{ L"XT_83KEY", L"*PNP0300\0" },
{ L"PCAT_86KEY", L"*PNP0301\0" },
{ L"PCXT_84KEY", L"*PNP0302\0" },
{ L"XT_84KEY", L"*PNP0302\0" },
{ L"101-KEY", L"*PNP0303\0" },
{ L"OLI_83KEY", L"*PNP0304\0" },
{ L"ATT_301", L"*PNP0304\0" },
{ L"OLI_102KEY", L"*PNP0305\0" },
{ L"OLI_86KEY", L"*PNP0306\0" },
{ L"OLI_A101_102KEY", L"*PNP0309\0" },
{ L"ATT_302", L"*PNP030a\0" },
{ L"PCAT_ENHANCED", L"*PNP030b\0" },
{ L"PC98_106KEY", L"*nEC1300\0" },
{ L"PC98_LaptopKEY", L"*nEC1300\0" },
{ L"PC98_N106KEY", L"*PNP0303\0" },
{ NULL, NULL }
};
DATA_SEG("INITDATA")
static
PNP_MAPPER_DEVICE_ID PointerMap[] =
{
{ L"PS2 MOUSE", L"*PNP0F0E\0" },
{ L"SERIAL MOUSE", L"*PNP0F0C\0" },
{ L"MICROSOFT PS2 MOUSE", L"*PNP0F03\0" },
{ L"LOGITECH PS2 MOUSE", L"*PNP0F12\0" },
{ L"MICROSOFT INPORT MOUSE", L"*PNP0F02\0" },
{ L"MICROSOFT SERIAL MOUSE", L"*PNP0F01\0" },
{ L"MICROSOFT BALLPOINT SERIAL MOUSE", L"*PNP0F09\0" },
{ L"LOGITECH SERIAL MOUSE", L"*PNP0F08\0" },
{ L"MICROSOFT BUS MOUSE", L"*PNP0F00\0" },
{ L"NEC PC-9800 BUS MOUSE", L"*nEC1F00\0" },
{ NULL, NULL }
};
DATA_SEG("INITDATA")
static
PNP_DETECT_IDENTIFIER_MAP PnPMap[] =
{
{ L"SerialController", L"*PNP0501\0", 0 },
{ L"KeyboardController", L"*PNP0303\0", 0 },
#if defined(SARCH_PC98)
{ L"PointerController", L"*nEC1F00\0", 0 },
#else
{ L"PointerController", L"*PNP0F13\0", 0 },
#endif
{ L"ParallelController", L"*PNP0400\0", 0 },
{ L"FloppyDiskPeripheral", L"*PNP0700\0", 0 },
{ NULL, NULL, 0 }
{ L"SerialController", L"*PNP0501\0", NULL, 0 },
//{ L"KeyboardController", L"*PNP0303\0", NULL, 0 },
//{ L"PointerController", L"*PNP0F13\0", NULL, 0 },
{ L"KeyboardPeripheral", NULL, KeyboardMap, 0 },
{ L"PointerPeripheral", NULL, PointerMap, 0 },
{ L"ParallelController", L"*PNP0400\0", NULL, 0 },
{ L"FloppyDiskPeripheral", L"*PNP0700\0", NULL, 0 },
{ NULL, NULL, NULL, 0 }
};
/* FUNCTIONS *****************************************************************/
static
CODE_SEG("INIT")
PWSTR
IopMapPeripheralId(
_In_ PCUNICODE_STRING Value,
_In_ PPNP_MAPPER_DEVICE_ID DeviceList)
{
ULONG i;
UNICODE_STRING CmpId;
for (i = 0; DeviceList[i].TypeName; i++)
{
RtlInitUnicodeString(&CmpId, DeviceList[i].TypeName);
if (RtlCompareUnicodeString(Value, &CmpId, FALSE) == 0)
break;
}
return DeviceList[i].PnPId;
}
static
CODE_SEG("INIT")
PWSTR
IopMapDetectedDeviceId(
_In_ PUNICODE_STRING DetectId,
_In_ PUNICODE_STRING Value,
_Out_ PULONG DeviceIndex)
{
ULONG i;
@ -71,6 +137,9 @@ IopMapDetectedDeviceId(
if (RtlCompareUnicodeString(DetectId, &CmpId, FALSE) == 0)
{
*DeviceIndex = PnPMap[i].Counter++;
if (PnPMap[i].PeripheralMap)
return IopMapPeripheralId(Value, PnPMap[i].PeripheralMap);
break;
}
}
@ -370,16 +439,16 @@ IopEnumerateDetectedDevices(
ValueName.Length -= sizeof(WCHAR);
}
pHardwareId = IopMapDetectedDeviceId(RelativePath, &DeviceIndex);
pHardwareId = IopMapDetectedDeviceId(RelativePath, &ValueName, &DeviceIndex);
if (!pHardwareId)
{
/* Unknown key path */
DPRINT("Unknown key path '%wZ'\n", RelativePath);
DPRINT("Unknown key path '%wZ' value '%wZ'\n", RelativePath, &ValueName);
goto nextdevice;
}
/* Prepare hardware id key (hardware id value without final \0) */
HardwareIdKey.Length = wcslen(pHardwareId) * sizeof(WCHAR);
HardwareIdKey.Length = (USHORT)wcslen(pHardwareId) * sizeof(WCHAR);
HardwareIdKey.MaximumLength = HardwareIdKey.Length + sizeof(UNICODE_NULL) * 2;
HardwareIdKey.Buffer = pHardwareId;