mirror of
https://github.com/reactos/reactos.git
synced 2024-07-03 03:04:22 +00:00
[I8042PRT]
- "All this file is a big hack and should be removed one day…" - Today is that day! setup.c is no more! [TXTSETUP.SIF] - Move keyboard drivers to the Keyboard.Load section [USETUP] - Add a small keyboard class installation hack - USB keyboards now load during 1st stage svn path=/trunk/; revision=55750
This commit is contained in:
parent
07bda3bb7e
commit
e7d4fc1686
|
@ -51,6 +51,9 @@ InstallDriver(
|
|||
ULONG Disposition;
|
||||
NTSTATUS Status;
|
||||
BOOLEAN deviceInstalled = FALSE;
|
||||
UNICODE_STRING UpperFiltersU = RTL_CONSTANT_STRING(L"UpperFilters");
|
||||
LPWSTR keyboardClass = L"kbdclass\0";
|
||||
BOOLEAN keyboardDevice = FALSE;
|
||||
|
||||
/* Check if we know the hardware */
|
||||
if (!SetupFindFirstLineW(hInf, L"HardwareIdsDatabase", HardwareId, &Context))
|
||||
|
@ -63,9 +66,14 @@ InstallDriver(
|
|||
if (!SetupFindFirstLineW(hInf, L"BootBusExtenders.Load", Driver, &Context)
|
||||
&& !SetupFindFirstLineW(hInf, L"BusExtenders.Load", Driver, &Context)
|
||||
&& !SetupFindFirstLineW(hInf, L"SCSI.Load", Driver, &Context)
|
||||
&& !SetupFindFirstLineW(hInf, L"InputDevicesSupport.Load", Driver, &Context)
|
||||
&& !SetupFindFirstLineW(hInf, L"Keyboard.Load", Driver, &Context))
|
||||
return FALSE;
|
||||
&& !SetupFindFirstLineW(hInf, L"InputDevicesSupport.Load", Driver, &Context))
|
||||
{
|
||||
if (!SetupFindFirstLineW(hInf, L"Keyboard.Load", Driver, &Context))
|
||||
return FALSE;
|
||||
|
||||
keyboardDevice = TRUE;
|
||||
}
|
||||
|
||||
if (!INF_GetDataField(&Context, 1, &ImagePath))
|
||||
return FALSE;
|
||||
|
||||
|
@ -130,6 +138,17 @@ InstallDriver(
|
|||
ImagePath,
|
||||
(wcslen(ImagePath) + 1) * sizeof(WCHAR));
|
||||
|
||||
if (keyboardDevice)
|
||||
{
|
||||
DPRINT1("Installing keyboard class driver for '%S'\n", DeviceId);
|
||||
NtSetValueKey(hDeviceKey,
|
||||
&UpperFiltersU,
|
||||
0,
|
||||
REG_MULTI_SZ,
|
||||
keyboardClass,
|
||||
(wcslen(keyboardClass) + 2) * sizeof(WCHAR));
|
||||
}
|
||||
|
||||
/* Associate device with the service we just filled */
|
||||
Status = NtSetValueKey(
|
||||
hDeviceKey,
|
||||
|
|
|
@ -31,7 +31,7 @@ isapnp.sys=,,,,,,,,,,,,4
|
|||
kdcom.dll=,,,,,,,,,,,,2
|
||||
disk.sys=,,,,,,x,,,,,,4
|
||||
floppy.sys=,,,,,,x,,,,,,4
|
||||
i8042prt.sys=,,,,,,x,,,,,,4
|
||||
i8042prt.sys=,,,,,,,,,,,,4
|
||||
hidclass.sys=,,,,,,,,,,,,4
|
||||
hidparse.sys=,,,,,,,,,,,,4
|
||||
hidusb.sys=,,,,,,,,,,,,4
|
||||
|
@ -83,6 +83,7 @@ USB\COMPOSITE = usbccgp
|
|||
GenDisk = disk
|
||||
USB\Class_03 = hidusb
|
||||
GENERIC_HID_DEVICE = hidusb
|
||||
*PNP0303 = i8042prt
|
||||
|
||||
[BootBusExtenders.Load]
|
||||
acpi = acpi.sys
|
||||
|
@ -97,7 +98,10 @@ usbhub = usbhub.sys
|
|||
usbccgp = usbccgp.sys
|
||||
hidusb = hidusb.sys
|
||||
usbstor = usbstor.sys
|
||||
|
||||
[Keyboard.Load]
|
||||
kbdhid = kbdhid.sys
|
||||
i8042prt = i8042prt.sys
|
||||
|
||||
[BusExtenders.Load]
|
||||
pciide = pciide.sys
|
||||
|
|
|
@ -11,7 +11,6 @@ add_library(i8042prt SHARED
|
|||
ps2pp.c
|
||||
readwrite.c
|
||||
registry.c
|
||||
setup.c
|
||||
i8042prt.rc)
|
||||
|
||||
set_module_type(i8042prt kernelmodedriver)
|
||||
|
|
|
@ -530,8 +530,5 @@ DriverEntry(
|
|||
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = i8042InternalDeviceControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_PNP] = i8042Pnp;
|
||||
|
||||
if (IsFirstStageSetup())
|
||||
return i8042AddLegacyKeyboard(DriverObject, RegistryPath);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -438,14 +438,3 @@ NTSTATUS
|
|||
ReadRegistryEntries(
|
||||
IN PUNICODE_STRING RegistryPath,
|
||||
OUT PI8042_SETTINGS Settings);
|
||||
|
||||
/* setup.c */
|
||||
|
||||
BOOLEAN
|
||||
IsFirstStageSetup(
|
||||
VOID);
|
||||
|
||||
NTSTATUS
|
||||
i8042AddLegacyKeyboard(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PUNICODE_STRING RegistryPath);
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<file>ps2pp.c</file>
|
||||
<file>readwrite.c</file>
|
||||
<file>registry.c</file>
|
||||
<file>setup.c</file>
|
||||
<file>i8042prt.rc</file>
|
||||
<pch>i8042prt.h</pch>
|
||||
</module>
|
||||
|
|
|
@ -411,15 +411,9 @@ StartProcedure(
|
|||
}
|
||||
|
||||
/* First detect the mouse and then the keyboard!
|
||||
If we do it the other way round, some systems throw away settings like the keyboard translation, when detecting the mouse.
|
||||
|
||||
Don't detect the mouse if we're in 1st stage setup! */
|
||||
if(!IsFirstStageSetup())
|
||||
{
|
||||
TRACE_(I8042PRT, "Detecting mouse\n");
|
||||
i8042DetectMouse(DeviceExtension);
|
||||
}
|
||||
|
||||
If we do it the other way round, some systems throw away settings like the keyboard translation, when detecting the mouse. */
|
||||
TRACE_(I8042PRT, "Detecting mouse\n");
|
||||
i8042DetectMouse(DeviceExtension);
|
||||
TRACE_(I8042PRT, "Detecting keyboard\n");
|
||||
i8042DetectKeyboard(DeviceExtension);
|
||||
|
||||
|
|
|
@ -1,152 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS i8042 (ps/2 keyboard-mouse controller) driver
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/input/i8042prt/setup.c
|
||||
* PURPOSE: Create a legacy PDO during ReactOS installation
|
||||
* PROGRAMMERS: Copyright 2006-2007 Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
/* NOTE:
|
||||
* All this file is a big hack and should be removed one day...
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include "i8042prt.h"
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
#define KEYBOARD_DATA_PORT 0x60
|
||||
#define KEYBOARD_CONTROL_PORT 0x64
|
||||
#define KEYBOARD_IRQ 1
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
BOOLEAN
|
||||
IsFirstStageSetup(
|
||||
VOID)
|
||||
{
|
||||
UNICODE_STRING PathU = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\Setup");
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE hSetupKey = (HANDLE)NULL;
|
||||
NTSTATUS Status;
|
||||
BOOLEAN ret = TRUE;
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes, &PathU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL);
|
||||
Status = ZwOpenKey(&hSetupKey, KEY_QUERY_VALUE, &ObjectAttributes);
|
||||
|
||||
if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||
ret = TRUE;
|
||||
else
|
||||
ret = FALSE;
|
||||
|
||||
if (hSetupKey != (HANDLE)NULL)
|
||||
ZwClose(hSetupKey);
|
||||
INFO_(I8042PRT, "IsFirstStageSetup() returns %s\n", ret ? "YES" : "NO");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
AddRegistryEntry(
|
||||
IN PCWSTR PortTypeName,
|
||||
IN PUNICODE_STRING DeviceName,
|
||||
IN PCWSTR RegistryPath)
|
||||
{
|
||||
UNICODE_STRING PathU = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\HARDWARE\\DEVICEMAP");
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE hDeviceMapKey = (HANDLE)-1;
|
||||
HANDLE hPortKey = (HANDLE)-1;
|
||||
UNICODE_STRING PortTypeNameU;
|
||||
NTSTATUS Status;
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes, &PathU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL);
|
||||
Status = ZwOpenKey(&hDeviceMapKey, 0, &ObjectAttributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
WARN_(I8042PRT, "ZwOpenKey() failed with status 0x%08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&PortTypeNameU, PortTypeName);
|
||||
InitializeObjectAttributes(&ObjectAttributes, &PortTypeNameU, OBJ_KERNEL_HANDLE, hDeviceMapKey, NULL);
|
||||
Status = ZwCreateKey(&hPortKey, KEY_SET_VALUE, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
WARN_(I8042PRT, "ZwCreateKey() failed with status 0x%08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
Status = ZwSetValueKey(hPortKey, DeviceName, 0, REG_SZ, (PVOID)RegistryPath, wcslen(RegistryPath) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
WARN_(I8042PRT, "ZwSetValueKey() failed with status 0x%08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
cleanup:
|
||||
if (hDeviceMapKey != (HANDLE)-1)
|
||||
ZwClose(hDeviceMapKey);
|
||||
if (hPortKey != (HANDLE)-1)
|
||||
ZwClose(hPortKey);
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
i8042AddLegacyKeyboard(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PUNICODE_STRING RegistryPath)
|
||||
{
|
||||
UNICODE_STRING KeyboardName = RTL_CONSTANT_STRING(L"\\Device\\KeyboardPort8042");
|
||||
PI8042_DEVICE_TYPE DeviceExtension = NULL;
|
||||
PDEVICE_OBJECT Pdo = NULL;
|
||||
NTSTATUS Status;
|
||||
|
||||
TRACE_(I8042PRT, "i8042AddLegacyKeyboard()\n");
|
||||
|
||||
/* Create a named PDO */
|
||||
Status = IoCreateDevice(
|
||||
DriverObject,
|
||||
sizeof(I8042_DEVICE_TYPE),
|
||||
&KeyboardName,
|
||||
FILE_DEVICE_8042_PORT,
|
||||
FILE_DEVICE_SECURE_OPEN,
|
||||
TRUE,
|
||||
&Pdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
WARN_(I8042PRT, "IoCreateDevice() failed with status 0x%08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Initialize device extension */
|
||||
DeviceExtension = (PI8042_DEVICE_TYPE)Pdo->DeviceExtension;
|
||||
RtlZeroMemory(DeviceExtension, sizeof(I8042_DEVICE_TYPE));
|
||||
*DeviceExtension = PhysicalDeviceObject;
|
||||
Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
|
||||
/* Add FDO at the top of the PDO */
|
||||
Status = i8042AddDevice(DriverObject, Pdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
WARN_(I8042PRT, "i8042AddDevice() failed with status 0x%08lx\n", Status);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* We will send the IRP_MN_START_DEVICE later when kbdclass looks for legacy drivers */
|
||||
AddRegistryEntry(L"KeyboardPort", &KeyboardName, RegistryPath->Buffer);
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
/* Yes, completly forget the Pdo pointer, as we will never
|
||||
* have to unload this driver during first stage setup.
|
||||
*/
|
||||
|
||||
cleanup:
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (Pdo)
|
||||
IoDeleteDevice(Pdo);
|
||||
}
|
||||
return Status;
|
||||
}
|
Loading…
Reference in a new issue