[U-Boot] [PATCH] MPC512x: workaround data corruption for unaligned local bus accesses
Joakim Tjernlund
joakim.tjernlund at transmode.se
Tue Jun 29 16:21:39 CEST 2010
>
> Wolfgang Denk <wd at denx.de> wrote on 2010/06/29 14:55:44:
> >
> > Dear Joakim Tjernlund,
> >
> > In message <OFEB4E68BC.F6B8C9D0-ONC1257751.0045AE08-C1257751.
> > 0045DA56 at transmode.se> you wrote:
> > >
> > > > I could not come up with a better name... What is "align32wrap"
> > > > supposed to mean?
> > >
> > > mpc5200_memcpy_fromio() resp. mpc5200_memcpy_toio()?
> >
> > No. It's not only MPC5200, but also MPC521x. It's not I/O in general,
> > but only I/O from the Local Bus. And even then only unaliged read
> > access.
> >
> > But memcpy_for_unaligned_read_from_local_bus() was too long for me,
> > and memcpy_furflb() too cryptic ;-)
>
> memcpy_align_src()?
>
> Jocke
BTW, perhaps this memcpy I wrote for uClibc long time ago
is useful? You can easily change dst or src alignment:
void *memcpy(void *to, const void *from, size_t len)
{
unsigned long rem, chunks, tmp1, tmp2;
unsigned char *tmp_to;
unsigned char *tmp_from = (unsigned char *)from;
chunks = len / 8;
tmp_from -= 4;
tmp_to = to - 4;
if (!chunks)
goto lessthan8;
rem = (unsigned long )tmp_to % 4;
if (rem)
goto align;
copy_chunks:
do {
/* make gcc to load all data, then store it */
tmp1 = *(unsigned long *)(tmp_from+4);
tmp_from += 8;
tmp2 = *(unsigned long *)tmp_from;
*(unsigned long *)(tmp_to+4) = tmp1;
tmp_to += 8;
*(unsigned long *)tmp_to = tmp2;
} while (--chunks);
lessthan8:
len = len % 8;
if (len >= 4) {
tmp_from += 4;
tmp_to += 4;
*(unsigned long *)(tmp_to) = *(unsigned long *)(tmp_from);
len -= 4;
}
if (!len)
return to;
tmp_from += 3;
tmp_to += 3;
do {
*++tmp_to = *++tmp_from;
} while (--len);
return to;
align:
/* ???: Do we really need to generate the carry flag here? If not, then:
rem -= 4; */
rem = 4 - rem;
len -= rem;
do {
*(tmp_to+4) = *(tmp_from+4);
++tmp_from;
++tmp_to;
} while (--rem);
chunks = len / 8;
if (chunks)
goto copy_chunks;
goto lessthan8;
}
More information about the U-Boot
mailing list