Ah, but memcpy is generic in the sense that it’s able to copy 1, 3, 46, 48,
64, 908 and 1024 bytes all the same. It just does 4-byte at a time copies
when the length, source and destination allows it (which in x86-case is as
long as remaining length > 4 bytes).
A copy routine built along these lines using READ_REGISTER_BUFFER_ULONG
could be used too:
void memcpy_from_BUFFER(void *src, void *dest, size_t len)
{
READ_REGISTER_BUFFER_ULONG((PULONG)src, (PULONG)dest, (len >> 2));
if (len & 3)
{
UCHAR *src1, *dest1;
src1 = (UCHAR *src) + (len & ~3);
dest1 = (UCHAR *dest) + (len & ~3);
READ_REGISTER_BUFFER_UCHAR(src1, dest1, len & 3);
}
}
And of course, using WRITE_REGISTER_BUFFER_XXXX if you want to get the data
written in the opposite direction. The only problem with this would be on
machines that do not support unaligned addresses, in which case you’d have
to support the unaligned cases.
–
Mats
-----Original Message-----
From: Roddy, Mark [mailto:xxxxx@stratus.com]
Sent: Thursday, July 01, 2004 4:28 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] memcpy to PCI Adapter
See Mats’ reply. memcpy on x86 uses 32bit transfers as does
READ_REGISTER_BUFFER_ULONG, so I don’t see what you are
getting out of this
other than unportable code.
For host->device operations on an x86 architecture you are asking for
obscure timing related bugs by not using the HAL
WRITE_REGISTER_* routines.
=====================
Mark Roddy
-----Original Message-----
From: cd [mailto:xxxxx@hotmail.com]
Sent: Thursday, July 01, 2004 11:16 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] memcpy to PCI Adapter
Of course, but my code assumes a generic memcpy routine. On
other OSes,
memcpy like routines are provided. I just have to do it all myself for
Windows.
I just changed my OS code to use memcpy for x86 machines and
a custom memcpy
using WRITE/READ_REGISTER* optimized for aligned source/destination on
non-x86 machines.
“Roddy, Mark” wrote in message
news:xxxxx@ntdev…
> You will of course get better performance using
READ_REGISTER_BUFFER_ULONG,
> right?
>
>
>
> =====================
> Mark Roddy
>
> -----Original Message-----
> From: cd [mailto:xxxxx@hotmail.com]
> Sent: Thursday, July 01, 2004 9:27 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] memcpy to PCI Adapter
>
> At one time I had used memcpy and the virtual address returned from
> MmMapIoSpace to move data to a PCI adapter’s memory. Knowing that this
works
> for Intel x86 architectures but possibly not others, I switched to the
> READ_REGISTER_BUFFER_UCHAR, but the performance dropped considerably
> since memcpy optimizes for quad word transfers.
>
> Is there a generic READ_REGISTER_BUFFER that mimics memcpy’s
> optimization (this would be similar to memcpy_toio and memcpy_fromio
> in the Linux
world)?
> Does everyone have to recreate memcpy using the READ_REGISTER_BUFFER_*
> routines?
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@stratus.com To
> unsubscribe send a blank email to xxxxx@lists.osr.com
>
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com