--- trunk/reactos/drivers/dd/serial/create.c 2005-05-15 08:30:35 UTC (rev 15295)
+++ trunk/reactos/drivers/dd/serial/create.c 2005-05-15 09:29:30 UTC (rev 15296)
@@ -17,17 +17,13 @@
IN PIRP Irp)
{
PIO_STACK_LOCATION Stack;
- PFILE_OBJECT FileObject;
PSERIAL_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
DPRINT("Serial: IRP_MJ_CREATE\n");
Stack = IoGetCurrentIrpStackLocation(Irp);
- FileObject = Stack->FileObject;
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- ASSERT(FileObject);
-
if (Stack->Parameters.Create.Options & FILE_DIRECTORY_FILE)
{
CHECKPOINT;
@@ -35,14 +31,6 @@
goto ByeBye;
}
- if (FileObject->FileName.Length != 0 ||
- FileObject->RelatedFileObject != NULL)
- {
- CHECKPOINT;
- Status = STATUS_ACCESS_DENIED;
- goto ByeBye;
- }
-
if(DeviceExtension->IsOpened)
{
DPRINT("Serial: COM%lu is already opened\n", DeviceExtension->ComPort);
--- trunk/reactos/drivers/dd/serial/devctrl.c 2005-05-15 08:30:35 UTC (rev 15295)
+++ trunk/reactos/drivers/dd/serial/devctrl.c 2005-05-15 09:29:30 UTC (rev 15296)
@@ -51,60 +51,29 @@
IN PSERIAL_DEVICE_EXTENSION DeviceExtension,
IN ULONG NewBaudRate)
{
+ ULONG BaudRate;
USHORT divisor;
PUCHAR ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
- ULONG BaudRate;
NTSTATUS Status = STATUS_SUCCESS;
- if (NewBaudRate & SERIAL_BAUD_USER)
- {
- BaudRate = NewBaudRate & ~SERIAL_BAUD_USER;
- divisor = (USHORT)(BAUD_CLOCK / (CLOCKS_PER_BIT * BaudRate));
- }
- else
- {
- switch (NewBaudRate)
- {
- case SERIAL_BAUD_075: divisor = 0x600; BaudRate = 75; break;
- case SERIAL_BAUD_110: divisor = 0x400; BaudRate = 110; break;
- case SERIAL_BAUD_134_5: divisor = 0x360; BaudRate = 134; break;
- case SERIAL_BAUD_150: divisor = 0x300; BaudRate = 150; break;
- case SERIAL_BAUD_300: divisor = 0x180; BaudRate = 300; break;
- case SERIAL_BAUD_600: divisor = 0xc0; BaudRate = 600; break;
- case SERIAL_BAUD_1200: divisor = 0x60; BaudRate = 1200; break;
- case SERIAL_BAUD_1800: divisor = 0x40; BaudRate = 1800; break;
- case SERIAL_BAUD_2400: divisor = 0x30; BaudRate = 2400; break;
- case SERIAL_BAUD_4800: divisor = 0x18; BaudRate = 4800; break;
- case SERIAL_BAUD_7200: divisor = 0x10; BaudRate = 7200; break;
- case SERIAL_BAUD_9600: divisor = 0xc; BaudRate = 9600; break;
- case SERIAL_BAUD_14400: divisor = 0x8; BaudRate = 14400; break;
- case SERIAL_BAUD_38400: divisor = 0x3; BaudRate = 38400; break;
- case SERIAL_BAUD_57600: divisor = 0x2; BaudRate = 57600; break;
- case SERIAL_BAUD_115200: divisor = 0x1; BaudRate = 115200; break;
- case SERIAL_BAUD_56K: divisor = 0x2; BaudRate = 57600; break;
- case SERIAL_BAUD_128K: divisor = 0x1; BaudRate = 115200; break;
- default: Status = STATUS_INVALID_PARAMETER;
- }
- }
+ divisor = (USHORT)(BAUD_CLOCK / (CLOCKS_PER_BIT * NewBaudRate));
+ BaudRate = BAUD_CLOCK / (CLOCKS_PER_BIT * divisor);
+ Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
if (NT_SUCCESS(Status))
{
- Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
- if (NT_SUCCESS(Status))
- {
- UCHAR Lcr;
- DPRINT("Serial: SerialSetBaudRate(COM%lu, %lu Bauds)\n", DeviceExtension->ComPort, BaudRate);
- /* Set Bit 7 of LCR to expose baud registers */
- Lcr = READ_PORT_UCHAR(SER_LCR(ComPortBase));
- WRITE_PORT_UCHAR(SER_LCR(ComPortBase), Lcr | SR_LCR_DLAB);
- /* Write the baud rate */
- WRITE_PORT_UCHAR(SER_DLL(ComPortBase), divisor & 0xff);
- WRITE_PORT_UCHAR(SER_DLM(ComPortBase), divisor >> 8);
- /* Switch back to normal registers */
- WRITE_PORT_UCHAR(SER_LCR(ComPortBase), Lcr);
+ UCHAR Lcr;
+ DPRINT("Serial: SerialSetBaudRate(COM%lu, %lu Bauds)\n", DeviceExtension->ComPort, BaudRate);
+ /* Set Bit 7 of LCR to expose baud registers */
+ Lcr = READ_PORT_UCHAR(SER_LCR(ComPortBase));
+ WRITE_PORT_UCHAR(SER_LCR(ComPortBase), Lcr | SR_LCR_DLAB);
+ /* Write the baud rate */
+ WRITE_PORT_UCHAR(SER_DLL(ComPortBase), divisor & 0xff);
+ WRITE_PORT_UCHAR(SER_DLM(ComPortBase), divisor >> 8);
+ /* Switch back to normal registers */
+ WRITE_PORT_UCHAR(SER_LCR(ComPortBase), Lcr);
- IoReleaseRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
- }
+ IoReleaseRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
}
if (NT_SUCCESS(Status))
@@ -244,16 +213,14 @@
| SERIAL_BAUD_150 | SERIAL_BAUD_300 | SERIAL_BAUD_600 | SERIAL_BAUD_1200
| SERIAL_BAUD_1800 | SERIAL_BAUD_2400 | SERIAL_BAUD_4800 | SERIAL_BAUD_7200
| SERIAL_BAUD_9600 | SERIAL_BAUD_USER;
- pCommProp->MaxBaud = SERIAL_BAUD_9600;
+ pCommProp->MaxBaud = SERIAL_BAUD_USER;
if (DeviceExtension->UartType >= Uart16450)
{
pCommProp->SettableBaud |= SERIAL_BAUD_14400 | SERIAL_BAUD_19200 | SERIAL_BAUD_38400;
- pCommProp->MaxBaud = SERIAL_BAUD_38400;
}
if (DeviceExtension->UartType >= Uart16550)
{
pCommProp->SettableBaud |= SERIAL_BAUD_56K | SERIAL_BAUD_57600 | SERIAL_BAUD_115200 | SERIAL_BAUD_128K;
- pCommProp->MaxBaud = SERIAL_BAUD_115200;
}
pCommProp->SettableData = SERIAL_DATABITS_5 | SERIAL_DATABITS_6 | SERIAL_DATABITS_7 | SERIAL_DATABITS_8;
--- trunk/reactos/drivers/dd/serial/pnp.c 2005-05-15 08:30:35 UTC (rev 15295)
+++ trunk/reactos/drivers/dd/serial/pnp.c 2005-05-15 09:29:30 UTC (rev 15296)
@@ -154,7 +154,7 @@
ASSERT(DeviceExtension);
ASSERT(DeviceExtension->PnpState == dsStopped);
- DeviceExtension->BaudRate = 19200 | SERIAL_BAUD_USER;
+ DeviceExtension->BaudRate = 19200;
DeviceExtension->BaseAddress = 0;
Dirql = 0;
for (i = 0; i < ResourceList->Count; i++)
@@ -308,8 +308,33 @@
switch (MinorFunction)
{
- case IRP_MN_START_DEVICE:
+ /* FIXME: do all these minor functions
+ IRP_MN_QUERY_REMOVE_DEVICE 0x1
+ IRP_MN_REMOVE_DEVICE 0x2
{
+ DPRINT("Serial: IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
+ IoAcquireRemoveLock
+ IoReleaseRemoveLockAndWait
+ pass request to DeviceExtension-LowerDriver
+ disable interface
+ IoDeleteDevice(Fdo) and/or IoDetachDevice
+ break;
+ }
+ IRP_MN_CANCEL_REMOVE_DEVICE 0x3
+ IRP_MN_STOP_DEVICE 0x4
+ IRP_MN_QUERY_STOP_DEVICE 0x5
+ IRP_MN_CANCEL_STOP_DEVICE 0x6
+ IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations (optional) 0x7
+ IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations (optional) 0x7
+ IRP_MN_QUERY_INTERFACE (optional) 0x8
+ IRP_MN_QUERY_CAPABILITIES (optional) 0x9
+ IRP_MN_FILTER_RESOURCE_REQUIREMENTS (optional) 0xd
+ IRP_MN_QUERY_PNP_DEVICE_STATE (optional) 0x14
+ IRP_MN_DEVICE_USAGE_NOTIFICATION (required or optional) 0x16
+ IRP_MN_SURPRISE_REMOVAL 0x17
+ */
+ case IRP_MN_START_DEVICE: /* 0x0 */
+ {
BOOLEAN ConflictDetected;
DPRINT("Serial: IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
@@ -355,29 +380,27 @@
Stack->Parameters.StartDevice.AllocatedResources);
break;
}
- /* IRP_MN_QUERY_STOP_DEVICE (FIXME: required) */
- /* IRP_MN_STOP_DEVICE (FIXME: required) */
- /* IRP_MN_CANCEL_STOP_DEVICE (FIXME: required) */
- /* IRP_MN_QUERY_REMOVE_DEVICE (FIXME: required) */
- /* case IRP_MN_REMOVE_DEVICE (FIXME: required) */
- /*{
- DPRINT("Serial: IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
- IoAcquireRemoveLock
- IoReleaseRemoveLockAndWait
- pass request to DeviceExtension-LowerDriver
- disable interface
- IoDeleteDevice(Fdo) and/or IoDetachDevice
+ case IRP_MN_QUERY_DEVICE_RELATIONS: /* (optional) 0x7 */
+ {
+ switch (Stack->Parameters.QueryDeviceRelations.Type)
+ {
+ case BusRelations:
+ {
+ DPRINT("Serial: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
+ return ForwardIrpAndForget(DeviceObject, Irp);
+ }
+ case RemovalRelations:
+ {
+ DPRINT("Serial: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
+ return ForwardIrpAndForget(DeviceObject, Irp);
+ }
+ default:
+ DPRINT1("Serial: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
+ Stack->Parameters.QueryDeviceRelations.Type);
+ return ForwardIrpAndForget(DeviceObject, Irp);
+ }
break;
- }*/
- /* IRP_MN_CANCEL_REMOVE_DEVICE (FIXME: required) */
- /* IRP_MN_SURPRISE_REMOVAL (FIXME: required) */
- /* IRP_MN_QUERY_CAPABILITIES (optional) */
- /* IRP_MN_QUERY_PNP_DEVICE_STATE (optional) */
- /* IRP_MN_FILTER_RESOURCE_REQUIREMENTS (optional) */
- /* IRP_MN_DEVICE_USAGE_NOTIFICATION (FIXME: required or optional ???) */
- /* IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations (optional) */
- /* IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations (optional) */
- /* IRP_MN_QUERY_INTERFACE (optional) */
+ }
default:
{
DPRINT1("Serial: unknown minor function 0x%x\n", MinorFunction);