On Thu, 29 Mar 2001, Peter Lueg wrote:

> Hi, list
>
> anybody who can tell me how to access 16Bit PCMCIA memory while still using
> longs? If I try to copy a mmapped region from PCMCIA memory space to some
> buffer
> using memcpy, I apparently only get the lower half words copied, the upper ones
> containing garbage.
>
> Can I tell the compile how to handle certain variables so that he generates
> half word accesses automagically?
>
> Do I have to write my own memcpy which uses 16Bit acceses only or is there an
> alternate routine which does the job?

You should craft your own.  Something like the following might do what you
want:

memcpy_from_pcmcia(void *dst, const void *src, int nbr)
{
        const unsigned short *s = src;
        unsigned long *d = *dst;

        while (nbr--) {
                *d++ = (s[0] | (s[2] << 16));
                s += 2;
        }
}

memcpy_to_pcmcia(void *dst, void *src, int nbr)
{
        const unsigned long *s = src;
        unsigned short *d = dst;

        while ((nbr -= 2) > 0) {
                *d = *s;
                d += 2;
                *d = *s >> 16;
                d += 2;
                s++;
        }
}


Completely untested though.


Nicolas


_______________________________________________
http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
Please visit the above address for information on this list.

Reply via email to