Aparna Argade wrote:
Hi,
I have to read/write data of size > 1 MB to my PCIExpress endpoint
device from a wdm function driver. I am thinking of using WRITE/
READ_REGISTER_BUFFER_UCHAR for the same. I could not find any mention
about maximum size of the buffer, which these APIs can handle.
Note that you almost CERTAINLY do not want to use
READ_REGISTER_BUFFER_UCHAR. You want READ_REGISTER_BUFFER_ULONG.
Otherwise, you’re just wasting cycles.
These aren’t really APIs. They are essentially macros that generate the
“rep movs” instruction. Now, that necessarily implies that it writes to
consecutive addressses. Thus, you need to make sure you have a
megabyte’s worth of address space mapped on your device. For example,
if you copy a megabyte to address 0 in your device’s address space, it
will write dwords to 0, 4, 8, C, 10, etc., on through FFFF0, FFFF4,
FFFF8, and FFFFC.
All of these functions are basically synonyms for RtlMoveMemory or
memmove. That’s what I’d use for this function.
I have following questions.
1.a. Can I use READ/ WRITE_REGISTER_BUFFER_UCHAR APIs for data
transfers of size > 1MB?
Yes. You can write as much data as you have address space.
1.b. These APIs do not return any status. How will I know whether the
transfer was successful?
The only way it can fail is if one of the addresses touches an unmapped
page, in which case you’ll get a blue screen. Other than that, they
cannot fail.
1.c. If I use these APIs then I need not worry about the
synchronization mechanism because HAL takes care for the same. Is this
correct?
Synchronization of what? It’s just moving a block of memory from here
to there. There is nothing to synchronize.
- There can be another alternative of taking the help of PCI bus
driver. Does pci bus driver handle IRP_MJ_READ/ WRITE sent by function
drivers?
If yes, then I can create an IRP with IRP_MJ_READ/ WRITE, pass on to
lower driver and wait for completion.
I doubt that the PCI bus driver has any read/write functionality, but
even if it did, you wouldn’t want to use it.
- Which approach is better?
Just write the bytes yourself. RtlMoveMemory,
READ_REGISTER_BUFFER_ULONG, or *pBuffer = 0.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.