CACHE_FLUSH()

Flush cache lines associated with a data buffer

Synopsis:

#include <sys/cache.h>

CACHE_FLUSH(struct cache_ctrl *cinfo, 
            void *vaddr, 
            uint64_t paddr, 
            size_t len);

Arguments:

cinfo
A pointer the the structure that was initially passed to cache_init().
vaddr
The virtual address of the buffer; this is a pointer to the data in the driver's virtual address space.
paddr
The physical address of the buffer: this is typically in the same address space that the external device will use to reference the data. The physical address is obtained by calling mem_offset64(). Since this function is fairly costly, drivers typically allocate a pool of data buffers at initialization (e.g. by calling mmap() with the MAP_PHYS and MAP_ANON flags), and predetermine the physical addresses of the data.
len
The number of bytes in the buffer, for which cached data should be flushed to memory.

Library:

libcache

Use the -l cache option to qcc to link against this library.

Description:

This macro is used to flush any cache lines associated with a data buffer out to memory. This routine ensures that any modifications that have been made to the data by the CPU will be reflected by the contents of memory, and thus an external device reading the data won't retrieve stale data. For more information about cache coherency, see the entry for cache_init().


Note: This macro was added in QNX Momentics 6.3.0 SP2.

Before using the CACHE_*() macros on ARM and MIPS platforms, the calling thread must obtain I/O privileges by calling ThreadCtl(), specifying the _NTO_TCTL_IO flag:

ThreadCtl( _NTO_TCTL_IO, 0 );

Failing to do so may result in a SIGILL (illegal instruction) signal.

Environment variables:

The following environment variables, if they exist, affect the behavior of this function:

CACHE_NOP
Instructs the library that the CACHE_FLUSH() and CACHE_INVAL() macros should have no effect.
CACHE_MSYNC
Instructs the library that the CACHE_FLUSH() and CACHE_INVAL() macros should use the msync() C library call to perform cache synchronization.

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes

Caveats:

CACHE_FLUSH() is implemented as a macro.

See also:

cache_fini(), cache_init(), CACHE_INVAL()