xref: /openbsd-src/lib/libarch/mips64/cacheflush.3 (revision d2d7435a5fd3a7e4c9892f307ecd76a8855717e3)
1.\"	$OpenBSD: cacheflush.3,v 1.2 2010/09/26 15:12:03 jmc Exp $
2.\"
3.\" Copyright (c) 2009 Miodrag Vallat.
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 26 2010 $
18.Dt CACHEFLUSH 3 mips64
19.Os
20.Sh NAME
21.Nm cacheflush ,
22.Nm _flush_cache
23.Nd CPU cache synchronization functions
24.Sh SYNOPSIS
25.In machine/sysarch.h
26.Ft int
27.Fn cacheflush "void *addr" "int nbytes" "int cache"
28.Ft int
29.Fn _flush_cache "char *addr" "int nbytes" "int cache"
30.Sh DESCRIPTION
31.Fn cacheflush
32allows a process to synchronize the contents of the processor caches with
33main memory.
34Since MIPS processors have separate instruction and data caches, this
35function allows for dynamically generated code to run correctly.
36.Pp
37.Nm
38operates on a contiguous memory range in the current process address space,
39starting at address
40.Fa addr
41and
42.Fa nbytes
43bytes long.
44The caches to be synchronized are specified in the
45.Fa cache
46argument with one of the following values:
47.Pp
48.Bl -tag -width "ICACHEXXX" -compact -offset ind
49.It Dv ICACHE
50synchronize the instruction cache
51.It Dv DCACHE
52synchronize the data cache
53.It Dv BCACHE
54synchronize both the instruction and data caches
55.El
56.Pp
57.Nm _flush_cache
58is an alias for the
59.Nm cacheflush
60function.
61.Sh RETURN VALUES
62Upon successful completion,
63.Nm
64returns zero.
65Otherwise, a value of \-1 is returned and
66.Va errno
67is set to indicate the error.
68.Sh ERRORS
69.Nm
70will fail if:
71.Bl -tag -width Er
72.It Bq Er EFAULT
73The address range specified by
74.Fa addr
75and
76.Fa nbytes
77is not part of the process allocated address space.
78.It Bq Er EINVAL
79.Fa cache
80is not valid.
81.El
82