Aligned malloc for dma and mbufs for powerpc ppc405gp

Gene Smith gds at chartertn.net
Thu Nov 11 03:56:36 UTC 2004


Feng, Shuchen wrote, On 11/09/2004 10:56 PM:
> For 32 bytes aligned, one can do :
> 
>   struct GTeth_softc *sc;
> 
>   /* Make certain elements e.g. descriptor lists are aligned. */
>   softc_mem = rtems_bsdnet_malloc(sizeof(*sc) + SOFTC_ALIGN, M_FREE,
> M_NOWAIT);
> 
>   /* Check for the very unlikely case of no memory. */
>   if (softc_mem == NULL)
>      rtems_panic("GT64260eth: OUT OF MEMORY");
> 
>   sc = (void *)(((long)softc_mem + SOFTC_ALIGN) & ~SOFTC_ALIGN);
>   memset(sc, 0, sizeof(*sc))

Thank, this does the trick. Driver now works! The 405pgr manual states 
you need 4KB alignment in one place for descriptors and 8 byte in 
another. I stayed with 4KB for now to be safe.

> 
> 
> Please note:
> An mbuf cluster is aligned on a cluster-sized (2 kbyte) boundary.
> Network mbufs are aligned on an mbuf-sized (128 byte) boundary. 

So they are. Thanks for pointing this out.




More information about the users mailing list