1# zx_cache_flush
2
3## NAME
4
5<!-- Updated by update-docs-from-abigen, do not edit. -->
6
7cache_flush - Flush CPU data and/or instruction caches
8
9## SYNOPSIS
10
11<!-- Updated by update-docs-from-abigen, do not edit. -->
12
13```
14#include <zircon/syscalls.h>
15
16zx_status_t zx_cache_flush(const void* addr, size_t size, uint32_t options);
17```
18
19## DESCRIPTION
20
21`zx_cache_flush()` flushes CPU caches covering memory in the given
22virtual address range.  If that range of memory is not readable, then
23the thread may fault as it would for a data read.
24
25*options* is a bitwise OR of:
26
27 * **ZX_CACHE_FLUSH_DATA**
28
29   Clean (write back) data caches, so previous writes on this CPU are
30   visible in main memory.
31
32 * **ZX_CACHE_FLUSH_INVALIDATE**
33   (valid only when combined with **ZX_CACHE_FLUSH_DATA**)
34
35   Clean (write back) data caches and then invalidate data caches, so
36   previous writes on this CPU are visible in main memory and future
37   reads on this CPU see external changes to main memory.
38
39 * **ZX_CACHE_FLUSH_INSN**
40
41   Synchronize instruction caches with data caches, so previous writes
42   on this CPU are visible to instruction fetches.  If this is combined
43   with **ZX_CACHE_FLUSH_DATA**, then previous writes will be visible to
44   main memory as well as to instruction fetches.
45
46At least one of **ZX_CACHE_FLUSH_DATA** and **ZX_CACHE_FLUSH_INSN**
47must be included in *options*.
48
49## RIGHTS
50
51<!-- Updated by update-docs-from-abigen, do not edit. -->
52
53TODO(ZX-2399)
54
55## RETURN VALUE
56
57`zx_cache_flush()` returns **ZX_OK** on success, or an error code on failure.
58
59## ERRORS
60
61**ZX_ERR_INVALID_ARGS** *options* is invalid.
62