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