From 830e39cdb3204d6ae988282fdd9a4825c31f3a29 Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Wed, 22 Jun 2022 11:19:18 -0500 Subject: xemacps: Avoid using memset on device memory It is not safe to use memset with device memory. Device memory has strict access alignment requirements that memset may not respect since it can be optimized to use unaligned accesses. This avoids use of memset with device memory. --- .../XilinxProcessorIPLib/drivers/emacps/src/xemacps_bdring.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/embeddedsw/XilinxProcessorIPLib/drivers/emacps/src/xemacps_bdring.c b/embeddedsw/XilinxProcessorIPLib/drivers/emacps/src/xemacps_bdring.c index 829f37c..1cbfa18 100644 --- a/embeddedsw/XilinxProcessorIPLib/drivers/emacps/src/xemacps_bdring.c +++ b/embeddedsw/XilinxProcessorIPLib/drivers/emacps/src/xemacps_bdring.c @@ -225,7 +225,16 @@ LONG XEmacPs_BdRingCreate(XEmacPs_BdRing * RingPtr, UINTPTR PhysAddr, * - Clear the entire space * - Setup each BD's BDA field with the physical address of the next BD */ +#ifndef __rtems__ (void)memset((void *) VirtAddrLoc, 0, (RingPtr->Separation * BdCount)); +#else + unsigned char* mem = (unsigned char *) VirtAddrLoc; + int len = RingPtr->Separation * BdCount; + while (len-- > 0) { + *mem = 0; + mem++; + } +#endif BdVirtAddr = VirtAddrLoc; BdPhyAddr = PhysAddr + RingPtr->Separation; -- cgit v1.2.3