Register GUID_DEVINTERFACE_COMPORT for serial devices

Register GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR for serenum devices
Fix some comments

svn path=/trunk/; revision=14876
This commit is contained in:
Hervé Poussineau 2005-04-30 15:04:10 +00:00
parent 8293cc1006
commit 5c87a8787a
5 changed files with 45 additions and 38 deletions

View file

@ -18,11 +18,10 @@ SerenumAddDevice(
{ {
PDEVICE_OBJECT Fdo; PDEVICE_OBJECT Fdo;
PFDO_DEVICE_EXTENSION DeviceExtension; PFDO_DEVICE_EXTENSION DeviceExtension;
//UNICODE_STRING SymbolicLinkName;
NTSTATUS Status; NTSTATUS Status;
DPRINT("Serenum: SerenumAddDevice called. Pdo = %p\n", Pdo); DPRINT("Serenum: SerenumAddDevice called. Pdo = %p\n", Pdo);
/* Create new device object */ /* Create new device object */
Status = IoCreateDevice(DriverObject, Status = IoCreateDevice(DriverObject,
sizeof(FDO_DEVICE_EXTENSION), sizeof(FDO_DEVICE_EXTENSION),
@ -36,27 +35,22 @@ SerenumAddDevice(
DPRINT("Serenum: IoCreateDevice() failed with status 0x%08lx\n", Status); DPRINT("Serenum: IoCreateDevice() failed with status 0x%08lx\n", Status);
return Status; return Status;
} }
DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
RtlZeroMemory(DeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
/* Register device interface */ /* Register device interface */
#if 0 /* FIXME: activate */ Status = IoRegisterDeviceInterface(
Status = IoRegisterDeviceInterface(Pdo, &GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR, NULL, &SymbolicLinkName); Pdo,
&GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR,
NULL,
&DeviceExtension->SerenumInterfaceName);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("Serenum: IoRegisterDeviceInterface() failed with status 0x%08lx\n", Status); DPRINT("Serenum: IoRegisterDeviceInterface() failed with status 0x%08lx\n", Status);
goto ByeBye; IoDeleteDevice(Fdo);
return Status;
} }
DPRINT1("Serenum: IoRegisterDeviceInterface() returned '%wZ'\n", &SymbolicLinkName);
Status = IoSetDeviceInterfaceState(&SymbolicLinkName, TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT("Serenum: IoSetDeviceInterfaceState() failed with status 0x%08lx\n", Status);
goto ByeBye;
}
RtlFreeUnicodeString(&SymbolicLinkName);
#endif
DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
RtlZeroMemory(DeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
DeviceExtension->Common.IsFDO = TRUE; DeviceExtension->Common.IsFDO = TRUE;
DeviceExtension->Common.PnpState = dsStopped; DeviceExtension->Common.PnpState = dsStopped;
DeviceExtension->Pdo = Pdo; DeviceExtension->Pdo = Pdo;
@ -80,13 +74,22 @@ SerenumFdoStartDevice(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp) IN PIRP Irp)
{ {
PCOMMON_DEVICE_EXTENSION DeviceExtension; PFDO_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
DPRINT("Serenum: SerenumFdoStartDevice() called\n"); DPRINT("Serenum: SerenumFdoStartDevice() called\n");
DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension; DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(DeviceExtension->PnpState == dsStopped); ASSERT(DeviceExtension->Common.PnpState == dsStopped);
DeviceExtension->PnpState = dsStarted;
Status = IoSetDeviceInterfaceState(&DeviceExtension->SerenumInterfaceName, TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT("Serenum: IoSetDeviceInterfaceState() failed with status 0x%08lx\n", Status);
return Status;
}
DeviceExtension->Common.PnpState = dsStarted;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -66,6 +66,8 @@ typedef struct _FDO_DEVICE_EXTENSION
PDEVICE_OBJECT Pdo; PDEVICE_OBJECT Pdo;
IO_REMOVE_LOCK RemoveLock; IO_REMOVE_LOCK RemoveLock;
UNICODE_STRING SerenumInterfaceName;
PDEVICE_OBJECT AttachedPdo; PDEVICE_OBJECT AttachedPdo;
ULONG Flags; ULONG Flags;
} FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION; } FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
@ -122,7 +124,7 @@ SerenumDuplicateUnicodeString(
NTSTATUS NTSTATUS
SerenumInitMultiSzString( SerenumInitMultiSzString(
OUT PUNICODE_STRING Destination, OUT PUNICODE_STRING Destination,
... /* list of ANSI_STRINGs */); ... /* list of PCSZ */);
NTSTATUS NTSTATUS
ForwardIrpAndWait( ForwardIrpAndWait(

View file

@ -45,7 +45,7 @@ SerialCreate(
if(DeviceExtension->IsOpened) if(DeviceExtension->IsOpened)
{ {
DPRINT("Serial: COM%lu is already opened", DeviceExtension->ComPort); DPRINT("Serial: COM%lu is already opened\n", DeviceExtension->ComPort);
Status = STATUS_ACCESS_DENIED; Status = STATUS_ACCESS_DENIED;
goto ByeBye; goto ByeBye;
} }

View file

@ -26,15 +26,14 @@ SerialAddDeviceInternal(
NTSTATUS Status; NTSTATUS Status;
WCHAR DeviceNameBuffer[32]; WCHAR DeviceNameBuffer[32];
UNICODE_STRING DeviceName; UNICODE_STRING DeviceName;
//UNICODE_STRING SymbolicLinkName;
static ULONG DeviceNumber = 0; static ULONG DeviceNumber = 0;
static ULONG ComPortNumber = 1; static ULONG ComPortNumber = 1;
DPRINT("Serial: SerialAddDeviceInternal called\n"); DPRINT("Serial: SerialAddDeviceInternal called\n");
ASSERT(DeviceObject); ASSERT(DeviceObject);
ASSERT(Pdo); ASSERT(Pdo);
/* Create new device object */ /* Create new device object */
swprintf(DeviceNameBuffer, L"\\Device\\Serial%lu", DeviceNumber); swprintf(DeviceNameBuffer, L"\\Device\\Serial%lu", DeviceNumber);
RtlInitUnicodeString(&DeviceName, DeviceNameBuffer); RtlInitUnicodeString(&DeviceName, DeviceNameBuffer);
@ -55,23 +54,13 @@ SerialAddDeviceInternal(
RtlZeroMemory(DeviceExtension, sizeof(SERIAL_DEVICE_EXTENSION)); RtlZeroMemory(DeviceExtension, sizeof(SERIAL_DEVICE_EXTENSION));
/* Register device interface */ /* Register device interface */
#if 0 /* FIXME: activate */ Status = IoRegisterDeviceInterface(Pdo, &GUID_DEVINTERFACE_COMPORT, NULL, &DeviceExtension->SerialInterfaceName);
Status = IoRegisterDeviceInterface(Pdo, &GUID_DEVINTERFACE_COMPORT, NULL, &SymbolicLinkName);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("Serial: IoRegisterDeviceInterface() failed with status 0x%08x\n", Status); DPRINT("Serial: IoRegisterDeviceInterface() failed with status 0x%08x\n", Status);
goto ByeBye; goto ByeBye;
} }
DPRINT1("Serial: IoRegisterDeviceInterface() returned '%wZ'\n", &SymbolicLinkName);
Status = IoSetDeviceInterfaceState(&SymbolicLinkName, TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT("Serial: IoSetDeviceInterfaceState() failed with status 0x%08x\n", Status);
goto ByeBye;
}
RtlFreeUnicodeString(&SymbolicLinkName);
#endif
DeviceExtension->SerialPortNumber = DeviceNumber++; DeviceExtension->SerialPortNumber = DeviceNumber++;
if (pComPortNumber == NULL) if (pComPortNumber == NULL)
DeviceExtension->ComPort = ComPortNumber++; DeviceExtension->ComPort = ComPortNumber++;
@ -254,6 +243,15 @@ SerialPnpStartDevice(
return Status; return Status;
} }
/* Activate serial interface */
Status = IoSetDeviceInterfaceState(&DeviceExtension->SerialInterfaceName, TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT("Serial: IoSetDeviceInterfaceState() failed with status 0x%08x\n", Status);
IoDeleteSymbolicLink(&LinkName);
return Status;
}
/* Connect interrupt and enable them */ /* Connect interrupt and enable them */
Status = IoConnectInterrupt( Status = IoConnectInterrupt(
&DeviceExtension->Interrupt, SerialInterruptService, &DeviceExtension->Interrupt, SerialInterruptService,
@ -264,6 +262,7 @@ SerialPnpStartDevice(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("Serial: IoConnectInterrupt() failed with status 0x%08x\n", Status); DPRINT("Serial: IoConnectInterrupt() failed with status 0x%08x\n", Status);
IoSetDeviceInterfaceState(&DeviceExtension->SerialInterfaceName, FALSE);
IoDeleteSymbolicLink(&LinkName); IoDeleteSymbolicLink(&LinkName);
return Status; return Status;
} }
@ -366,6 +365,7 @@ SerialPnp(
IoAcquireRemoveLock IoAcquireRemoveLock
IoReleaseRemoveLockAndWait IoReleaseRemoveLockAndWait
pass request to DeviceExtension-LowerDriver pass request to DeviceExtension-LowerDriver
disable interface
IoDeleteDevice(Fdo) and/or IoDetachDevice IoDeleteDevice(Fdo) and/or IoDetachDevice
break; break;
}*/ }*/

View file

@ -100,6 +100,8 @@ typedef struct _SERIAL_DEVICE_EXTENSION
CIRCULAR_BUFFER OutputBuffer; CIRCULAR_BUFFER OutputBuffer;
KSPIN_LOCK OutputBufferLock; KSPIN_LOCK OutputBufferLock;
UNICODE_STRING SerialInterfaceName;
/* Current values */ /* Current values */
UCHAR MCR; /* Base+4, Modem Control Register */ UCHAR MCR; /* Base+4, Modem Control Register */
UCHAR MSR; /* Base+6, Modem Status Register */ UCHAR MSR; /* Base+6, Modem Status Register */