]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Written by Ralf Baechle (ralf@waldorf-gmbh.de), |
2 | .\" Copyright (c) 1994, 1995 Waldorf GMBH | |
3 | .\" | |
e4a74ca8 | 4 | .\" SPDX-License-Identifier: GPL-2.0-or-later |
fea681da | 5 | .\" |
45186a5d | 6 | .TH CACHEFLUSH 2 2021-03-22 "Linux man-pages (unreleased)" |
fea681da MK |
7 | .SH NAME |
8 | cacheflush \- flush contents of instruction and/or data cache | |
e8a9acc5 AC |
9 | .SH LIBRARY |
10 | Standard C library | |
8fc3b2cf | 11 | .RI ( libc ", " \-lc ) |
fea681da MK |
12 | .SH SYNOPSIS |
13 | .nf | |
cf14bdbd | 14 | .B #include <sys/cachectl.h> |
68e4db0a | 15 | .PP |
d75c2ffe | 16 | .BI "int cacheflush(void *" addr ", int "nbytes ", int "cache ); |
fea681da | 17 | .fi |
08811c14 AC |
18 | .PP |
19 | .IR Note : | |
20 | On some architectures, | |
21 | there is no glibc wrapper for this system call; see NOTES. | |
fea681da | 22 | .SH DESCRIPTION |
e511ffb6 | 23 | .BR cacheflush () |
988db661 | 24 | flushes the contents of the indicated cache(s) for the |
0cff29b7 MK |
25 | user addresses in the range |
26 | .I addr | |
988db661 | 27 | to |
cd415e73 | 28 | .IR (addr+nbytes\-1) . |
0daa9e92 | 29 | .I cache |
0cff29b7 | 30 | may be one of: |
fea681da MK |
31 | .TP |
32 | .B ICACHE | |
33 | Flush the instruction cache. | |
34 | .TP | |
35 | .B DCACHE | |
36 | Write back to memory and invalidate the affected valid cache lines. | |
37 | .TP | |
38 | .B BCACHE | |
c13182ef | 39 | Same as |
14ee3bff | 40 | .BR (ICACHE|DCACHE) . |
47297adb | 41 | .SH RETURN VALUE |
e511ffb6 | 42 | .BR cacheflush () |
a084d816 MK |
43 | returns 0 on success. |
44 | On error, it returns \-1 and sets | |
c13182ef | 45 | .I errno |
a084d816 | 46 | to indicate the error. |
fea681da MK |
47 | .SH ERRORS |
48 | .TP | |
49 | .B EFAULT | |
988db661 | 50 | Some or all of the address range |
0cff29b7 | 51 | .I addr |
988db661 | 52 | to |
cd415e73 | 53 | .I (addr+nbytes\-1) |
0cff29b7 | 54 | is not accessible. |
fea681da MK |
55 | .TP |
56 | .B EINVAL | |
0cff29b7 | 57 | .I cache |
988db661 | 58 | is not one of |
0cff29b7 | 59 | .BR ICACHE , |
988db661 MK |
60 | .BR DCACHE , |
61 | or | |
1ae6b2c7 | 62 | .B BCACHE |
7949b871 | 63 | (but see BUGS). |
3113c7f3 | 64 | .SH STANDARDS |
d5e8624c | 65 | Historically, this system call was available on all MIPS UNIX variants |
7bbc267a RB |
66 | including RISC/os, IRIX, Ultrix, NetBSD, OpenBSD, and FreeBSD |
67 | (and also on some non-UNIX MIPS operating systems), so that | |
68 | the existence of this call in MIPS operating systems is a de-facto | |
69 | standard. | |
70 | .SS Caveat | |
71 | .BR cacheflush () | |
72 | should not be used in programs intended to be portable. | |
266df083 | 73 | On Linux, this call first appeared on the MIPS architecture, |
7bbc267a RB |
74 | but nowadays, Linux provides a |
75 | .BR cacheflush () | |
76 | system call on some other architectures, but with different arguments. | |
d7e7ab0e | 77 | .SH NOTES |
08811c14 AC |
78 | .SS Architecture-specific variants |
79 | Glibc provides a wrapper for this system call, | |
80 | with the prototype shown in SYNOPSIS, | |
81 | for the following architectures: | |
82 | ARC, CSKY, MIPS, and NIOS2. | |
83 | .PP | |
84 | On some other architectures, | |
85 | Linux provides this system call, with different arguments: | |
86 | .TP | |
87 | M68K: | |
adce9485 | 88 | .nf |
08811c14 AC |
89 | .BI "int cacheflush(unsigned long " addr ", int " scope ", int " cache , |
90 | .BI " unsigned long " len ); | |
adce9485 | 91 | .fi |
08811c14 AC |
92 | .TP |
93 | SH: | |
adce9485 | 94 | .nf |
08811c14 | 95 | .BI "int cacheflush(unsigned long " addr ", unsigned long " len ", int " op ); |
adce9485 | 96 | .fi |
08811c14 AC |
97 | .TP |
98 | NDS32: | |
adce9485 | 99 | .nf |
08811c14 | 100 | .BI "int cacheflush(unsigned int " start ", unsigned int " end ", int " cache ); |
adce9485 | 101 | .fi |
08811c14 AC |
102 | .PP |
103 | On the above architectures, | |
104 | glibc does not provide a wrapper for this system call; call it using | |
105 | .BR syscall (2). | |
106 | .SS GCC alternative | |
d7e7ab0e AC |
107 | Unless you need the finer grained control that this system call provides, |
108 | you probably want to use the GCC built-in function | |
109 | .BR __builtin___clear_cache (), | |
110 | which provides a portable interface | |
111 | across platforms supported by GCC and compatible compilers: | |
112 | .PP | |
113 | .in +4n | |
114 | .EX | |
115 | .BI "void __builtin___clear_cache(void *" begin ", void *" end ); | |
116 | .EE | |
117 | .in | |
118 | .PP | |
119 | On platforms that don't require instruction cache flushes, | |
120 | .BR __builtin___clear_cache () | |
121 | has no effect. | |
122 | .PP | |
123 | .IR Note : | |
124 | On some GCC-compatible compilers, | |
125 | the prototype for this built-in function uses | |
126 | .I char * | |
127 | instead of | |
128 | .I void * | |
129 | for the parameters. | |
fea681da | 130 | .SH BUGS |
7bbc267a | 131 | Linux kernels older than version 2.6.11 ignore the |
c13182ef MK |
132 | .I addr |
133 | and | |
134 | .I nbytes | |
7bbc267a | 135 | arguments, making this function fairly expensive. |
9b8ff97a | 136 | Therefore, the whole cache is always flushed. |
efeece04 | 137 | .PP |
d5e8624c | 138 | This function always behaves as if |
1ae6b2c7 | 139 | .B BCACHE |
7bbc267a RB |
140 | has been passed for the |
141 | .I cache | |
142 | argument and does not do any error checking on the | |
143 | .I cache | |
144 | argument. |