]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/cacheflush.2
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / 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.\"
45186a5d 6.TH CACHEFLUSH 2 2021-03-22 "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>
68e4db0a 15.PP
d75c2ffe 16.BI "int cacheflush(void *" addr ", int "nbytes ", int "cache );
fea681da 17.fi
08811c14
AC
18.PP
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).
3113c7f3 64.SH STANDARDS
d5e8624c 65Historically, this system call was available on all MIPS UNIX variants
7bbc267a
RB
66including RISC/os, IRIX, Ultrix, NetBSD, OpenBSD, and FreeBSD
67(and also on some non-UNIX MIPS operating systems), so that
68the existence of this call in MIPS operating systems is a de-facto
69standard.
70.SS Caveat
71.BR cacheflush ()
72should not be used in programs intended to be portable.
266df083 73On Linux, this call first appeared on the MIPS architecture,
7bbc267a
RB
74but nowadays, Linux provides a
75.BR cacheflush ()
76system call on some other architectures, but with different arguments.
d7e7ab0e 77.SH NOTES
08811c14
AC
78.SS Architecture-specific variants
79Glibc provides a wrapper for this system call,
80with the prototype shown in SYNOPSIS,
81for the following architectures:
82ARC, CSKY, MIPS, and NIOS2.
83.PP
84On some other architectures,
85Linux provides this system call, with different arguments:
86.TP
87M68K:
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
93SH:
adce9485 94.nf
08811c14 95.BI "int cacheflush(unsigned long " addr ", unsigned long " len ", int " op );
adce9485 96.fi
08811c14
AC
97.TP
98NDS32:
adce9485 99.nf
08811c14 100.BI "int cacheflush(unsigned int " start ", unsigned int " end ", int " cache );
adce9485 101.fi
08811c14
AC
102.PP
103On the above architectures,
104glibc does not provide a wrapper for this system call; call it using
105.BR syscall (2).
106.SS GCC alternative
d7e7ab0e
AC
107Unless you need the finer grained control that this system call provides,
108you probably want to use the GCC built-in function
109.BR __builtin___clear_cache (),
110which provides a portable interface
111across 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
119On platforms that don't require instruction cache flushes,
120.BR __builtin___clear_cache ()
121has no effect.
122.PP
123.IR Note :
124On some GCC-compatible compilers,
125the prototype for this built-in function uses
126.I char *
127instead of
128.I void *
129for the parameters.
fea681da 130.SH BUGS
7bbc267a 131Linux kernels older than version 2.6.11 ignore the
c13182ef
MK
132.I addr
133and
134.I nbytes
7bbc267a 135arguments, making this function fairly expensive.
9b8ff97a 136Therefore, the whole cache is always flushed.
efeece04 137.PP
d5e8624c 138This function always behaves as if
1ae6b2c7 139.B BCACHE
7bbc267a
RB
140has been passed for the
141.I cache
142argument and does not do any error checking on the
143.I cache
144argument.