- about Non-Plug and Play Serial Device Connected to the RS-232 Port :-(
- Posted by laudraup on April 6th, 2004
hi All:-)
http://www.microsoft.com/technet/pro...5serie.mspx#XS
LTsection122121120120
in this article:
"Updating MS Windows NT 4.0 Serial Device Drivers for Windows 2000"
Now my smart card reader is in the case:
Non-Plug and Play Serial Device Connected to the RS-232 Port
And i have several questions:
(1) I know we should attach our FDO to the PDO created by the root bus
driver.
however,what is the relations between FDO Toaster.sys and FDO Serial.sys??
should we use IoAttachDeviceToDeviceStack in this case?
and how to send irp to open serial,to configure serial?
(2)
besides ,when install,how to inform the system such a smart card reader
would be installed ?
by the way , i use the follwing codes to get pointer to serial.sys,
.................................................. ...........................
.................................................. .........................
RtlInitUnicodeString( &devx->SerialDeviceName,L"\\Device\\Serial0" );
status = IoGetDeviceObjectPointer(
&devx->SerialDeviceName,
FILE_ALL_ACCESS,
&pFile,
&pSerialDO);
.................................................. ...........................
.................................................. ...........................
..
however,the returned pSerialDo's DriverObject seems to be SerEnum.sys, why?
- Posted by Eliyas Yakub [MSFT] on April 7th, 2004
1) There is no relation. They are two independent stacks. No you don't
attach the two stacks. You just open the serial stacks using
IoGetDeviceObjectPointer or ZwOpenFile and send requests to it. Read
http://www.wd-3.com/archive/SerialAttachedDevices.htm
2) My suggestion would be to follow the Bull TLP3 sample in the DDK
(src\smartcard).
--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx
- Posted by Walter Oney on April 13th, 2004
laudraup wrote:
Wrong. Should be readerx->SerialDeviceObject->StackSize -- that's who
you're sending the IRP to. If this were the source of your bug check,
you'd have gotten a different bug code related to not having enough IRP
stack locations, however.
Wrong. No need for a file object at all. If you were talking to a driver
that needed a file object, you would need to create your own dummy --
this one belongs to a handle that was opened and closed inside
IoGetDeviceObjectPointer. An IRP_MJ_CREATE and IRP_MJ_CLOSE was already
sent, and it would be wrong to pass the same file object in a new
IRP_MJ_CREATE.
This isn't necessary for a legacy attached device.
Wrong. IoCallDriver is going to set the DeviceObject pointer anyway. No
point in doing it yourself.
Wrong. The IRP comes pre-initialized. No need to set these fields to
zero.
Wrong. You initialized an event called "event" that would seem to be an
automatic variable. Your completion routine must be doing two things,
even though you didn't show it to us: setting the event, and calling
IoFreeIrp. How does it find the event pointer?
Wrong. Your completion routine undoubtedly called IoFreeIrp. This
statement could be the cause of your crash.
Where is the crash? To succeed as a driver programmer, you're going to
have to learn to use some kernel debugger to at least pin down the
location of faults. You owe it to the busy people who are trying to help
you on this forum to do at least that much homework.
--
Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Check out our schedule at http://www.oneysoft.com
- Posted by Alexander Grigoriev on April 13th, 2004
Note that some serial device drivers may require that the device was opened
(outstanding CREATE request without CLOSE), otherwise they would power the
hardware down. Even serial.sys may require that - on some machines the
serial port is powered down unless an application opens it. So the client
driver pretty much should keep FILE_OBJECT (returned by
IoGetDeviceObjectPointer) referenced, and can pass it along with IRPs, just
for any case.
"Walter Oney" <waltoney@oneysoft.com> wrote in message
news:407BBB93.F27E1C8F@oneysoft.com...
- Posted by laudraup on April 14th, 2004
Hi,thanks for ur reply!
As to how to send requests to the serial stacks,would you pls explain in
details??
I have successfully called IoGetDeviceObjectPointer to get the pointer to
serial,however,i failed
to open serial.
I did all the work in my dispath routine of IRP_MN_START_DEVICE,and try to
build an irp with MajorFunction IRP_MJ_CREATE
to open serial.returned BSOD, :-(
Source code as follows:
CallSerialOpen( IN PDEVICE_OBJECT DeviceObject )//the DeviceObject is the my
FDO
{
OpenIrp = IoAllocateIrp((DeviceObject->StackSize ),FALSE);
irpstack = IoGetNextIrpStackLocation( OpenIrp );
irpstack->FileObject = pFileObj;//the fileObject returned in IoGetDeviceObjectPointer
irpstack->MajorFunction = IRP_MJ_CREATE;
irpstack->DeviceObject = readerx->SerialDeviceObject;//saved the pointer to serial here
irpstack->Parameters.Create.Options = 0;
irpstack->Parameters.Create.ShareAccess = 0;
irpstack->Parameters.Create.FileAttributes = 0;
irpstack->Parameters.Create.EaLength = 0;
KeInitializeEvent(
&Event,
NotificationEvent,
FALSE
);
IoSetCompletionRoutine (
OpenIrp,
IoCompletion,//completion routine
DeviceObject,
TRUE,
TRUE,
TRUE
);
status = IoCallDriver(readerx->SerialDeviceObject, OpenIrp);
if (status == STATUS_PENDING)
{
status = KeWaitForSingleObject(
&Event,
Executive,
KernelMode,
FALSE,
NULL
);
ASSERT (STATUS_SUCCESS == status);
status = OpenIrp->IoStatus.Status;
}
}
when IoCallDriver executes ,a BSOD occurs ,which shows Non_Paged_Memory_Fault.
I have been puzzled for 2 days ,but what is the problem?
wishing you can help me.
TIA:-)
"Eliyas Yakub [MSFT]" <eliyasy@online.microsoft.com> wrote in message news:u$aYymMHEHA.3476@TK2MSFTNGP11.phx.gbl...