Aligned malloc for dma and mbufs for powerpc ppc405gp

Joel Sherrill <joel@OARcorp.com> joel.sherrill at OARcorp.com
Wed Nov 10 12:20:09 UTC 2004


There is a PR with a patch to add this to the heap/region/malloc
in RTEMS.  Unfortunately, it was against code that is now over
a year old and does not merge easily.  If someone would merge it
and resubmit the patch, I would merge it that day.

It also reduces the memory used by the heap internally.

--joel

Feng, Shuchen wrote:
> Gene Smith wrote :
> 
> 
>>I have a requirement to allocate a block of memory (on a 4KB boundary 
>>according to the manual) for dma descriptor. I also need to have my 
>>mbufs allocated on 32 byte boundaries as dma buffers. This is due to the
> 
> 
>>ppc405gp emac and mal devices and cache line boundaries. Is there a way 
>>to do this in rtems using the standard API? If not, any suggestions on 
>>how this should be done?
> 
> 
> 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))
> 
> 
> 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. 
> 
> You can reference the network driver for my mvme5500 BSP at
> http://www.nsls.bnl.gov/organization/UserScience/Detectors/Software
> 
> 
> 
>>Since my driver is not working I think this must be part of the problem.
> 
> 
> Yes, it has to be done right.
> 
> Regards,
> Kate


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985




More information about the users mailing list