src/ssx/ppc405/ppc405_cache_core.c
/// Flush and invalidate a range of addresses from the D-cache
///
/// \param p A pointer to a memory area to be invalidated.
///
/// \param bytes The size (in bytes) of the area to invalidate.
///
/// The dcache_flush() API is used to flush and invalidate an arbitrary range
/// of memory from the D-cache. Note that flushing is not a destructive
/// operation in the sense that no information is lost.  This API will flush
/// and invalidate all cache lines from the line containing the address \a p,
/// to the line containing the address \a p + \a size - 1.  (If \a size == 0
/// this call is a NOP.)  D-cache flush is more-or-less a no-op for data
/// either not in the cache or marked as non-cacheable.
///
/// This API always issues a sync() after the flush, even in the event of \a
/// size == 0.
///
/// \note For flushing small blocks of data where some alignmment constraints
/// are known it may be more efficient to use dcache_flush_line() rather than
/// this API.
Flush and invalidate a range of addresses from the D-cache
\param p A pointer to a memory area to be invalidated.

\param bytes The size (in bytes) of the area to invalidate.

The dcache_flush() API is used to flush and invalidate an arbitrary range
of memory from the D-cache. Note that flushing is not a destructive
operation in the sense that no information is lost.  This API will flush
and invalidate all cache lines from the line containing the address \a p,
to the line containing the address \a p + \a size - 1.

This API always issues a sync() after the flush, even in the event of \a
size == 0.

\note For flushing small blocks of data where some alignmment constraints
are known it may be more efficient to use dcache_flush_line() rather than
this API.
Flush and invalidate a range of addresses from the D - cache \ param p A pointer to a memory area to be invalidated . \ param bytes The size ( in bytes ) of the area to invalidate . The dcache_flush () API is used to flush and invalidate an arbitrary range of memory from the D - cache . Note that flushing is not a destructive operation in the sense that no information is lost . This API will flush and invalidate all cache lines from the line containing the address \ a p to the line containing the address \ a p + \ a size - 1 . This API always issues a sync () after the flush even in the event of \ a size == 0 . \ note For flushing small blocks of data where some alignmment constraints are known it may be more efficient to use dcache_flush_line () rather than this API .
void
dcache_flush(void* p, size_t bytes)
{
    size_t lines;
    if (bytes != 0)
    {
        lines = 1;
        bytes -=
            MIN((CACHE_LINE_SIZE - ((unsigned long)p % CACHE_LINE_SIZE)),
                bytes);
        lines += bytes / CACHE_LINE_SIZE;
        if (!cache_aligned(bytes))
        {
            lines++;
        }
        while (lines--)
        {
            dcbf(p);
            p += CACHE_LINE_SIZE;
        }
    }
    sync();
}
void dcache_flush ( void * p , size_t bytes ) { size_t lines ; if ( bytes != 0 ) { lines = 1 ; bytes -= MIN ( ( CACHE_LINE_SIZE - ( ( unsigned long ) p % CACHE_LINE_SIZE ) ) , bytes ) ; lines += bytes / CACHE_LINE_SIZE ; if ( ! cache_aligned ( bytes ) ) { lines ++ ; } while ( lines -- ) { dcbf ( p ) ; p += CACHE_LINE_SIZE ; } } sync ( ) ; }
Flush and invalidate a range of addresses from the D-cache
\param p A pointer to a memory area to be invalidated.
Flush and invalidate a range of addresses from the D - cache \ param p A pointer to a memory area to be invalidated .