[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Aligned malloc for dma and mbufs for powerpc ppc405gp
- Date: Wed, 10 Nov 2004 22:56:36 -0500
- From: gds at chartertn.net (Gene Smith)
- Subject: Aligned malloc for dma and mbufs for powerpc ppc405gp
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,
> /* 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.