Open device question

Our hardware product is a communication card with up to two hundred i/o ports to do dada transfer.

In Linux, the application can work in per port per processor environment . Each processor calls open to open the device and get a different file scripter. All the read, write and ioctl to the driver with the different file scripter so the driver knows which port it is.

I tried to do same way in Windows driver. It seems get problem. The application could call CreateFile many times and get different handless, but the parameter device objectors pass to driver are all same. If the application calls readfile on port one or port two with different handle, the driver has no idea the read related which port.

Since how many i/o ports in the system is depend on how many cards plug in and what kind card is. There is no way to create different device name (something like port0, port1 …).

I wonder if I could employment in similar way in Windows driver. I hope experts here can help me to find a solution.

Thanks.

First, you should strongly consider using KMDF for your driver since it appears that you are just starting to write windows drivers. If you don’t use kmdf, you will have to implement pnp/power support in your driver and it will add to your complexity.

Second, what you want to use is the PFILE_OBJECT that represents each file handle. The PFILE_OBJECT is passed to your IRP_MJ_CREATE routine as well as each read/write IRP that you receive. During processing of create you can initialize FsContext or FsContext2 to integer (like an index value into an array in your device extension) or allocate a buffer and store it in either field. You can then use this field when processing the read/write/ioctl irp to know which port you want to manipulate.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@amtelco.com
Sent: Tuesday, December 18, 2007 12:11 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Open device question

Our hardware product is a communication card with up to two hundred i/o ports to do dada transfer.

In Linux, the application can work in per port per processor environment . Each processor calls open to open the device and get a different file scripter. All the read, write and ioctl to the driver with the different file scripter so the driver knows which port it is.

I tried to do same way in Windows driver. It seems get problem. The application could call CreateFile many times and get different handless, but the parameter device objectors pass to driver are all same. If the application calls readfile on port one or port two with different handle, the driver has no idea the read related which port.

Since how many i/o ports in the system is depend on how many cards plug in and what kind card is. There is no way to create different device name (something like port0, port1 …).

I wonder if I could employment in similar way in Windows driver. I hope experts here can help me to find a solution.

Thanks.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thank you very much for your help.

FILE_OBJECT seems solved my problem. What is KMDF for?

Bob Bao

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Tuesday, December 18, 2007 2:19 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Open device question

First, you should strongly consider using KMDF for your driver since it
appears that you are just starting to write windows drivers. If you
don’t use kmdf, you will have to implement pnp/power support in your
driver and it will add to your complexity.

Second, what you want to use is the PFILE_OBJECT that represents each
file handle. The PFILE_OBJECT is passed to your IRP_MJ_CREATE routine
as well as each read/write IRP that you receive. During processing of
create you can initialize FsContext or FsContext2 to integer (like an
index value into an array in your device extension) or allocate a buffer
and store it in either field. You can then use this field when
processing the read/write/ioctl irp to know which port you want to
manipulate.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@amtelco.com
Sent: Tuesday, December 18, 2007 12:11 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Open device question

Our hardware product is a communication card with up to two hundred i/o
ports to do dada transfer.

In Linux, the application can work in per port per processor
environment . Each processor calls open to open the device and get a
different file scripter. All the read, write and ioctl to the driver
with the different file scripter so the driver knows which port it is.

I tried to do same way in Windows driver. It seems get problem. The
application could call CreateFile many times and get different handless,
but the parameter device objectors pass to driver are all same. If the
application calls readfile on port one or port two with different
handle, the driver has no idea the read related which port.

Since how many i/o ports in the system is depend on how many cards plug
in and what kind card is. There is no way to create different device
name (something like port0, port1 …).

I wonder if I could employment in similar way in Windows driver. I hope
experts here can help me to find a solution.

Thanks.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

What does KMDF stand for? kernel mode driver framework, it is a part of WDF, windows driver foundation. What is used for? writing drivers and providing a well tested implementation of cancel safe queues, power management and pnp functionality as well as integrating i/o queues and dma into power/pnp state.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Bob Bao
Sent: Tuesday, December 18, 2007 12:47 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Open device question

Thank you very much for your help.

FILE_OBJECT seems solved my problem. What is KMDF for?

Bob Bao

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Tuesday, December 18, 2007 2:19 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Open device question

First, you should strongly consider using KMDF for your driver since it
appears that you are just starting to write windows drivers. If you
don’t use kmdf, you will have to implement pnp/power support in your
driver and it will add to your complexity.

Second, what you want to use is the PFILE_OBJECT that represents each
file handle. The PFILE_OBJECT is passed to your IRP_MJ_CREATE routine
as well as each read/write IRP that you receive. During processing of
create you can initialize FsContext or FsContext2 to integer (like an
index value into an array in your device extension) or allocate a buffer
and store it in either field. You can then use this field when
processing the read/write/ioctl irp to know which port you want to
manipulate.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@amtelco.com
Sent: Tuesday, December 18, 2007 12:11 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Open device question

Our hardware product is a communication card with up to two hundred i/o
ports to do dada transfer.

In Linux, the application can work in per port per processor
environment . Each processor calls open to open the device and get a
different file scripter. All the read, write and ioctl to the driver
with the different file scripter so the driver knows which port it is.

I tried to do same way in Windows driver. It seems get problem. The
application could call CreateFile many times and get different handless,
but the parameter device objectors pass to driver are all same. If the
application calls readfile on port one or port two with different
handle, the driver has no idea the read related which port.

Since how many i/o ports in the system is depend on how many cards plug
in and what kind card is. There is no way to create different device
name (something like port0, port1 …).

I wonder if I could employment in similar way in Windows driver. I hope
experts here can help me to find a solution.

Thanks.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

We did have windows driver for XP and Win2000 (ddk). We have not work on
wdk. The hardware gets more function, so the driver has to support it.

Thanks again for help.

Bob Bao

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Tuesday, December 18, 2007 2:55 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Open device question

What does KMDF stand for? kernel mode driver framework, it is a part of
WDF, windows driver foundation. What is used for? writing drivers and
providing a well tested implementation of cancel safe queues, power
management and pnp functionality as well as integrating i/o queues and
dma into power/pnp state.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bob Bao
Sent: Tuesday, December 18, 2007 12:47 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Open device question

Thank you very much for your help.

FILE_OBJECT seems solved my problem. What is KMDF for?

Bob Bao

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Tuesday, December 18, 2007 2:19 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Open device question

First, you should strongly consider using KMDF for your driver since it
appears that you are just starting to write windows drivers. If you
don’t use kmdf, you will have to implement pnp/power support in your
driver and it will add to your complexity.

Second, what you want to use is the PFILE_OBJECT that represents each
file handle. The PFILE_OBJECT is passed to your IRP_MJ_CREATE routine
as well as each read/write IRP that you receive. During processing of
create you can initialize FsContext or FsContext2 to integer (like an
index value into an array in your device extension) or allocate a buffer
and store it in either field. You can then use this field when
processing the read/write/ioctl irp to know which port you want to
manipulate.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@amtelco.com
Sent: Tuesday, December 18, 2007 12:11 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Open device question

Our hardware product is a communication card with up to two hundred i/o
ports to do dada transfer.

In Linux, the application can work in per port per processor
environment . Each processor calls open to open the device and get a
different file scripter. All the read, write and ioctl to the driver
with the different file scripter so the driver knows which port it is.

I tried to do same way in Windows driver. It seems get problem. The
application could call CreateFile many times and get different handless,
but the parameter device objectors pass to driver are all same. If the
application calls readfile on port one or port two with different
handle, the driver has no idea the read related which port.

Since how many i/o ports in the system is depend on how many cards plug
in and what kind card is. There is no way to create different device
name (something like port0, port1 …).

I wonder if I could employment in similar way in Windows driver. I hope
experts here can help me to find a solution.

Thanks.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer