Register GUID_DEVINTERFACE_COMPORT for serial devices
Register GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR for serenum devices
Fix some comments
Modified: trunk/reactos/drivers/bus/serenum/fdo.c
Modified: trunk/reactos/drivers/bus/serenum/serenum.h
Modified: trunk/reactos/drivers/dd/serial/create.c
Modified: trunk/reactos/drivers/dd/serial/pnp.c
Modified: trunk/reactos/drivers/dd/serial/serial.h

Modified: trunk/reactos/drivers/bus/serenum/fdo.c
--- trunk/reactos/drivers/bus/serenum/fdo.c	2005-04-30 14:53:41 UTC (rev 14875)
+++ trunk/reactos/drivers/bus/serenum/fdo.c	2005-04-30 15:04:10 UTC (rev 14876)
@@ -18,11 +18,10 @@
 {
 	PDEVICE_OBJECT Fdo;
 	PFDO_DEVICE_EXTENSION DeviceExtension;
-	//UNICODE_STRING SymbolicLinkName;
 	NTSTATUS Status;
-
+	
 	DPRINT("Serenum: SerenumAddDevice called. Pdo = %p\n", Pdo);
-   
+	
 	/* Create new device object */
 	Status = IoCreateDevice(DriverObject,
 	                        sizeof(FDO_DEVICE_EXTENSION),
@@ -36,27 +35,22 @@
 		DPRINT("Serenum: IoCreateDevice() failed with status 0x%08lx\n", Status);
 		return Status;
 	}
+	DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
+	RtlZeroMemory(DeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
 	
 	/* Register device interface */
-#if 0 /* FIXME: activate */
-	Status = IoRegisterDeviceInterface(Pdo, &GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR, NULL, &SymbolicLinkName);
+	Status = IoRegisterDeviceInterface(
+		Pdo,
+		&GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR,
+		NULL,
+		&DeviceExtension->SerenumInterfaceName);
 	if (!NT_SUCCESS(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.PnpState = dsStopped;
 	DeviceExtension->Pdo = Pdo;
@@ -80,14 +74,23 @@
 	IN PDEVICE_OBJECT DeviceObject,
 	IN PIRP Irp)
 {
-	PCOMMON_DEVICE_EXTENSION DeviceExtension;
+	PFDO_DEVICE_EXTENSION DeviceExtension;
+	NTSTATUS Status;
 	
 	DPRINT("Serenum: SerenumFdoStartDevice() called\n");
-	DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+	DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
 	
-	ASSERT(DeviceExtension->PnpState == dsStopped);
-	DeviceExtension->PnpState = dsStarted;
+	ASSERT(DeviceExtension->Common.PnpState == dsStopped);
 	
+	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;
 }
 

Modified: trunk/reactos/drivers/bus/serenum/serenum.h
--- trunk/reactos/drivers/bus/serenum/serenum.h	2005-04-30 14:53:41 UTC (rev 14875)
+++ trunk/reactos/drivers/bus/serenum/serenum.h	2005-04-30 15:04:10 UTC (rev 14876)
@@ -66,6 +66,8 @@
 	PDEVICE_OBJECT Pdo;
 	IO_REMOVE_LOCK RemoveLock;
 	
+	UNICODE_STRING SerenumInterfaceName;
+	
 	PDEVICE_OBJECT AttachedPdo;
 	ULONG Flags;
 } FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
@@ -122,7 +124,7 @@
 NTSTATUS
 SerenumInitMultiSzString(
 	OUT PUNICODE_STRING Destination,
-	... /* list of ANSI_STRINGs */);
+	... /* list of PCSZ */);
 
 NTSTATUS
 ForwardIrpAndWait(

Modified: trunk/reactos/drivers/dd/serial/create.c
--- trunk/reactos/drivers/dd/serial/create.c	2005-04-30 14:53:41 UTC (rev 14875)
+++ trunk/reactos/drivers/dd/serial/create.c	2005-04-30 15:04:10 UTC (rev 14876)
@@ -45,7 +45,7 @@
 	
 	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;
 		goto ByeBye;
 	}

Modified: trunk/reactos/drivers/dd/serial/pnp.c
--- trunk/reactos/drivers/dd/serial/pnp.c	2005-04-30 14:53:41 UTC (rev 14875)
+++ trunk/reactos/drivers/dd/serial/pnp.c	2005-04-30 15:04:10 UTC (rev 14876)
@@ -26,15 +26,14 @@
 	NTSTATUS Status;
 	WCHAR DeviceNameBuffer[32];
 	UNICODE_STRING DeviceName;
-	//UNICODE_STRING SymbolicLinkName;
 	static ULONG DeviceNumber = 0;
 	static ULONG ComPortNumber = 1;
-
+	
 	DPRINT("Serial: SerialAddDeviceInternal called\n");
 	
 	ASSERT(DeviceObject);
 	ASSERT(Pdo);
-   
+	
 	/* Create new device object */
 	swprintf(DeviceNameBuffer, L"\\Device\\Serial%lu", DeviceNumber);
 	RtlInitUnicodeString(&DeviceName, DeviceNameBuffer);
@@ -55,23 +54,13 @@
 	RtlZeroMemory(DeviceExtension, sizeof(SERIAL_DEVICE_EXTENSION));
 	
 	/* Register device interface */
-#if 0 /* FIXME: activate */
-	Status = IoRegisterDeviceInterface(Pdo, &GUID_DEVINTERFACE_COMPORT, NULL, &SymbolicLinkName);
+	Status = IoRegisterDeviceInterface(Pdo, &GUID_DEVINTERFACE_COMPORT, NULL, &DeviceExtension->SerialInterfaceName);
 	if (!NT_SUCCESS(Status))
 	{
 		DPRINT("Serial: IoRegisterDeviceInterface() failed with status 0x%08x\n", Status);
 		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++;
 	if (pComPortNumber == NULL)
 		DeviceExtension->ComPort = ComPortNumber++;
@@ -254,6 +243,15 @@
 		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 */
 	Status = IoConnectInterrupt(
 		&DeviceExtension->Interrupt, SerialInterruptService,
@@ -264,6 +262,7 @@
 	if (!NT_SUCCESS(Status))
 	{
 		DPRINT("Serial: IoConnectInterrupt() failed with status 0x%08x\n", Status);
+		IoSetDeviceInterfaceState(&DeviceExtension->SerialInterfaceName, FALSE);
 		IoDeleteSymbolicLink(&LinkName);
 		return Status;
 	}
@@ -366,6 +365,7 @@
 			IoAcquireRemoveLock
 			IoReleaseRemoveLockAndWait
 			pass request to DeviceExtension-LowerDriver
+			disable interface
 			IoDeleteDevice(Fdo) and/or IoDetachDevice
 			break;
 		}*/

Modified: trunk/reactos/drivers/dd/serial/serial.h
--- trunk/reactos/drivers/dd/serial/serial.h	2005-04-30 14:53:41 UTC (rev 14875)
+++ trunk/reactos/drivers/dd/serial/serial.h	2005-04-30 15:04:10 UTC (rev 14876)
@@ -100,6 +100,8 @@
 	CIRCULAR_BUFFER OutputBuffer;
 	KSPIN_LOCK OutputBufferLock;
 	
+	UNICODE_STRING SerialInterfaceName;
+	
 	/* Current values */
 	UCHAR MCR; /* Base+4, Modem Control Register */
 	UCHAR MSR; /* Base+6, Modem Status Register */